3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isJson($string) { $decoded = json_decode($string); return (json_last_error() == JSON_ERROR_NONE); } if ( isJson(123) ) { echo "valid JSON"; } else { echo "not valid JSON"; }
Output for 5.4.1, 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
valid JSON
Output for 5.2.0
Fatal error: Call to undefined function json_last_error() in /in/UCpb0 on line 5
Process exited with code 255.
Output for 5.0.5
Fatal error: Call to undefined function json_decode() in /in/UCpb0 on line 4
Process exited with code 255.
Output for 4.4.3
Fatal error: Call to undefined function: json_decode() in /in/UCpb0 on line 4
Process exited with code 255.

preferences:
85.66 ms | 409 KiB | 5 Q