$a = "sdgsdgsdgsdg";
$b = '{"name":"ewvwev"}';
json_decode($a);
$a_is_json_2 = (json_last_error() == JSON_ERROR_NONE);
json_decode($b);
$b_is_json_2 = (json_last_error() == JSON_ERROR_NONE);
return [
'a_is_json_1' => is_null(json_decode($a)),
'a_is_json_2' => $a_is_json_2,
'b_is_json_1' => is_null(json_decode($b)),
'b_is_json_2' => $b_is_json_2,
];得到的结果竟然是:{
"a_is_json_1": true,
"a_is_json_2": false,
"b_is_json_1": false,
"b_is_json_2": true
} 最佳答案