1、確認(rèn)文件無BOM頭
2、嘗試了如下多種方式去除非法字符串,但是仍然輸出NULL
$some_string = htmlspecialchars_decode($some_string);
$some_string = preg_replace("/\t/", " ", $some_string);
$some_string = preg_replace("/\n/", ' ', $some_string);
$some_string = str_replace("\n", ' ', $some_string);
$some_string = str_replace ('\n','', $some_string);
3、json_last_error()輸出4,Syntax error, malformed JSON
4、直接輸出字符串,瀏覽器能夠正常解析josn,如下截圖
4 回答

慕妹3146593
TA貢獻1820條經(jīng)驗 獲得超9個贊
$str=“json數(shù)據(jù)”;
dump($json_decode($str));
echo $errorinfo=json_last_error();
如果報錯4則
htmlspecialchars_decode($str);處理下
- 4 回答
- 0 關(guān)注
- 885 瀏覽
添加回答
舉報
0/150
提交
取消