json_last_error

PHP 5 >= 5.3.0, PHP 7, PHP 8
json_last_error - Returns the last error occurred
Manual
Code Examples

json_last_error( ): int

Returns the last error (if any) occurred during the last JSON encoding/decoding, which did not specify JSON_THROW_ON_ERROR.

Parameters

This function has no parameters.

Return Values

Returns an integer, the value can be one of the following constants:

JSON error codes
Constant Meaning Availability
JSON_ERROR_NONE No error has occurred
JSON_ERROR_DEPTH The maximum stack depth has been exceeded
JSON_ERROR_STATE_MISMATCH Invalid or malformed JSON
JSON_ERROR_CTRL_CHAR Control character error, possibly incorrectly encoded
JSON_ERROR_SYNTAX Syntax error
JSON_ERROR_UTF8 Malformed UTF-8 characters, possibly incorrectly encoded
JSON_ERROR_RECURSION One or more recursive references in the value to be encoded
JSON_ERROR_INF_OR_NAN One or more NAN or INF values in the value to be encoded
JSON_ERROR_UNSUPPORTED_TYPE A value of a type that cannot be encoded was given
JSON_ERROR_INVALID_PROPERTY_NAME A property name that cannot be encoded was given
JSON_ERROR_UTF16 Malformed UTF-16 characters, possibly incorrectly encoded

Related Functions

Example of json_last_error

Show all examples for json_last_error

PHP Version:


Function json_last_error:

JavaScript Object Notation Functions

Most used PHP functions