Home > PHP > Function > JSON > json_encode()

json_encode()

json_encode - Returns the JSON representation of a value

Syntax

string json_encode (mixed $value, int $options)

Arguments

  • value - The value being encoded. Can be any type except a resource. This function only works with UTF-8 encoded data.
  • options - Bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_FORCE_OBJECT.

Description

Returns a string containing the JSON representation of value.

Version

PHP 5.2.0, PECL json >= 1.2.0

Return value

Returns a JSON encoded string on success.