我遇到的问题跟他的差不多
调用app接口,然后php接受返回json串(验证之后格式正确):返回的数据跟实际字符不相符(多三个字符),
然后把php端改成 json头 还是不管用
app返回的:
string(121) ?{errorcode:0,errormsg:success,responsedata:{uid:36,sender_uid:37,error:0,error_msg:success}}
json_decode ->null
复制到文件中的:
string(118) {errorcode:0,errormsg:success,responsedata:{uid:36,sender_uid:37,error:0,error_msg:success}}
回复讨论(解决方案) bom头的原因吧
多的三个字符是 bom 头,去掉就可以了
比如接收到的在 $s 中,则
$a = json_decode(substr($s, 3));
多的三个字符是 bom 头,去掉就可以了
比如接收到的在 $s 中,则
$a = json_decode(substr($s, 3));
明天去公司了试一下
多的三个字符是 bom 头,去掉就可以了
比如接收到的在 $s 中,则
$a = json_decode(substr($s, 3));
用了百度推送了,又找了好几个小时,原来百度一个文件带bom头,蛋疼死了!!!谢谢了
bom头的原因吧
好了,谢谢呀
推荐一个json格式化工具,json校验工具, http://www.sojson.com
无广告加载快的工具