接口还回的数据自动在头部加上了BOM头,导致json_decode()转换失败.

 

$html = file_get_contents($url);
$html = str_replace(' ','',$html);
$userInfo = json_decode($html,true);

原因:接口还回的数据自动在头部加上了BOM头,导致转换失败。
解决方案:$html = str_replace(' ','',$html);

转载于:https://my.oschina.net/u/2376927/blog/1301701