how to check if the response is json php code example
Example 1: php check if json
function isJson($string) {
json_decode($string);
return (json_last_error() == JSON_ERROR_NONE);
}
Example 2: php check valid json string
@json_decode($page_str);
$json_OK= json_last_error() == JSON_ERROR_NONE;