Home  >  Article  >  Backend Development  >  php json_decode转换返回null

php json_decode转换返回null

WBOY
WBOYOriginal
2016-06-06 20:34:171019browse

php json_decode转换返回null,错误是UTF-8Malformed UTF-8 characters, possibly incorrectly encoded。
我转换的是一个别的服务器返回的json格式的字符串。我用mb_detect_encoding侦测了是utf8编码的。

回复内容:

php json_decode转换返回null,错误是UTF-8Malformed UTF-8 characters, possibly incorrectly encoded。
我转换的是一个别的服务器返回的json格式的字符串。我用mb_detect_encoding侦测了是utf8编码的。

试试 file_get_contents(); 先抓取服务器返回的内容;在json出来

在 Chrome 里打开接口地址,查看网络请求,可以看到 Reponse 中 Content-Type:text/html;charset=GBK。

php json_decode转换返回null

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