3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isJson($string) { json_decode($string); return (json_last_error() == JSON_ERROR_NONE); // return json_last_error(); // == JSON_ERROR_NONE); } $str1 = '{ "firstName": "Bidhan", "lastName": "Chatterjee", "age": 40, "email":"bidhan@example.com" }'; //echo json_decode($str1); $x=isJson($str1); echo $x; ?>

preferences:
38.57 ms | 402 KiB | 5 Q