Home  >  Article  >  Backend Development  >  json 数据回来 ,json_decode 之后为空

json 数据回来 ,json_decode 之后为空

WBOY
WBOYOriginal
2016-06-13 11:46:471048browse

json 数据返回 ,json_decode 之后为空
http://zhidao.baidu.com/link?url=kEYMQrLi41ZyC3Yo5XoN_QEbUentL2yVvcUg3seg_ZVksV2w5KBMudlQomrizXZiEoe3Uz0xtp7Moj9nRLBLNK

我遇到的问题跟他的差不多

调用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));

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn