3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isJson($string) { $decoded = json_decode($string); if ( !is_object($decoded) && !is_array($decoded) ) { return false; } return (json_last_error() == JSON_ERROR_NONE); } if ( isJson(123) ) { echo "valid JSON"; } else { echo "not valid JSON"; }

preferences:
51.32 ms | 405 KiB | 5 Q