为了账号安全,请及时绑定邮箱和手机立即绑定

php7 json_decode null

php7 json_decode null

PHP
狐的传说 2019-03-06 05:13:19
1、确认文件无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 回答

?
湖上湖

TA贡献2003条经验 获得超2个赞

json_decode($jsonStr, true);

你有加 true 这个参数了吗?

查看完整回答
反对 回复 2019-03-18
?
泛舟湖上清波郎朗

TA贡献1818条经验 获得超3个赞

信息比较少,不好判断,贴出$some_string来看看,或者说明下这个值是从哪里获取到的。。

查看完整回答
反对 回复 2019-03-18
?
慕妹3146593

TA贡献1820条经验 获得超9个赞

$str=“json数据”;                       
dump($json_decode($str));               
echo $errorinfo=json_last_error();            
如果报错4则  
htmlspecialchars_decode($str);处理下         
查看完整回答
反对 回复 2019-03-18
  • 4 回答
  • 0 关注
  • 854 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信