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"; }

preferences:
22.81 ms | 405 KiB | 5 Q