json_validate
Function • Added in PHP 8.3
Checks if a string contains valid JSON.
json_validate
Function synopsis
json_validate(
string $json,
int $depth = 512,
int $flags = 0
): bool
Parameters
$json
Typestring
The string to validate.
$depth
OptionalTypeint
Default value512
Maximum nesting depth of the structure being decoded.
The value must be greater than 0
,
and less than or equal to 2147483647
.
$flags
OptionalTypeint
Default value0
Currently only
JSON_INVALID_UTF8_IGNORE
is accepted.
$flags
accepts the following constant value
Return value
Typebool
Returns true
if the given string is syntactically valid JSON, otherwise
returns false
.
Changes to the json_validate
Function
PHP 8.3
- Function added
json_validate
Function Availability
json_validate
Function AvailabilityPHP Version | Availability |
---|---|
PHP 8.5Future Release | Yes |
PHP 8.4Upcoming Release | Yes |
PHP 8.3Supported (Latest) | Yes |
PHP 8.2Supported | No |
PHP 8.1Security-Fixes Only | No |
PHP 8.0Unsupported | No |
PHP 7.4Unsupported | No |
PHP 7.3Unsupported | No |
PHP 7.2Unsupported | No |
PHP 7.1Unsupported | No |
PHP 7.0Unsupported | No |
PHP 5.6Unsupported | No |
PHP 5.5Unsupported | No |
PHP 5.4Unsupported | No |
PHP 5.3Unsupported | No |