9
$a = '[{"function":"error_handler","class":"LP","type":"::","args":[256,"Call to undefined method LP_pdo::get_rorzxx() on D:\\MARK\\htdocs\\lessphptest\\application\\controllers\\users.php (23)","D:\\MARK\\htdocs\\lessphp\\LP.php",210,{"e":{"type":1,"message":"Call to undefined method LP_pdo::get_rorzxx()","file":"D:\\MARK\\htdocs\\lessphptest\\application\\controllers\\users.php","line":23}}]},{"file":"D:\\MARK\\htdocs\\lessphp\\LP.php","line":210,"function":"trigger_error","args":["Call to undefined method LP_pdo::get_rorzxx() on D:\\MARK\\htdocs\\lessphptest\\application\\controllers\\users.php (23)",256]},{"function":"shutdown","class":"LP","type":"::","args":[]}]';
$a = json_decode($a);
print_r($a);

echo json_last_error();

print_r()返回空白。

json_last_error()返回 4 即JSON_ERROR_SYNTAX

但是,当我在http://jsonlint.com/中运行 json 字符串时,它会返回Valid JSON

任何想法为什么?

4

2 回答 2

12

您需要\为 PHP 转义一次,为 JSON转义一次

D:\\\\....

于 2012-07-31T11:05:08.693 回答
0

尝试将编码设置为 utf-8 ...为我完成了这项工作

于 2012-07-31T11:11:12.980 回答