代码如下,$data未转码之前还是正常的json格式数据,一转码直接变成Null了,求教大神帮忙看看是什么问题啊
header("Content-type:text/html;charset=utf-8");
$url = "http://218.22.201.163/wic/api.php/early_warning/xcyjservice/U/administrator/P/wic/jw/118.589036,30.055954";
$postUrl = str_replace(' ', '%20', $url);
$param = '';
$curlPost = $param;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $postUrl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$data = curl_exec($ch);
curl_close($ch);
//var_dump($data);die;//
var_dump(json_decode($data, true));
------解决思路----------------------
你那个连接又 BOM 头!
json_decode(substr($data, 3), true)
就可以了
友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群