有什么方法可以在不使用 json_last_error()
的情况下检查变量是否是 PHP 中的有效 JSON 字符串?我的 PHP 版本低于 5.3.0。
最佳答案
$ob = json_decode($json);
if($ob === null) {
// $ob is null because the json cannot be decoded
}
关于php - 如何在 PHP 5.3.0 之前验证 JSON?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7841670/