一个关于json_decode()后显示为空的问题

lilihuyu2010 2014-08-27 03:28:18
代码如下,$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));
...全文
239 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lilihuyu2010 2014-08-27
  • 打赏
  • 举报
回复
引用 1 楼 xuzuning 的回复:
你那个连接又 BOM 头! json_decode(substr($data, 3), true) 就可以了
给力,我毕竟是菜鸟,连bom头都不知道,多谢斑竹了
xuzuning 2014-08-27
  • 打赏
  • 举报
回复
你那个连接又 BOM 头! json_decode(substr($data, 3), true) 就可以了

21,882

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧