php获取通过url的json数据,返回的是空值

WBOY
发布: 2016-06-23 13:57:12
原创
1563 人浏览过

http://php.net/api/apply.php?&apply={"apply":{"name":"4747474","site":"http:\/\/4444444444444444","icon":"47","information":"474","about":"747","weibo":"74444444444","email":"74444444444444444","moblie":"89742589633","isfree":"y","applytime":1349939108}}

这个是一个链接,我在这个页面上要怎么把那段json格式给接下出来呢?


回复讨论(解决方案)

$x = json_decode($_GET['apply']);

$x = json_decode($_GET['apply']);


得出来还是空值,可能那个字符串存在错误吧...

var_dump(json_decode($_GET['apply'],true));
看?出什麽?

var_dump(json_decode($_GET['apply'],true));
看?出什麽?


NULL

var_dump(json_decode(urldecode($_GET['apply']),true));

var_dump(json_decode(urldecode($_GET['apply']),true));



也是不行,最后我把那些多余的\去掉了,不知道是为啥啊?

print_r(json_decode('{"apply":{"name":"4747474","site":"http:\/\/4444444444444444","icon":"47","information":"474","about":"747","weibo":"74444444444","email":"74444444444444444","moblie":"89742589633","isfree":"y","applytime":1349939108}}'));
登录后复制
stdClass Object(    [apply] => stdClass Object        (            [name] => 4747474            [site] => http://4444444444444444            [icon] => 47            [information] => 474            [about] => 747            [weibo] => 74444444444            [email] => 74444444444444444            [moblie] => 89742589633            [isfree] => y            [applytime] => 1349939108        ))
登录后复制

PHP code
print_r(json_decode('{"apply":{"name":"4747474","site":"http:\/\/4444444444444444","icon":"47","information":"474","about":"747","weibo":"74444444444","email":"74444444444444444","moblie":"……



嗯,谢谢了

LZ地址中参数apply前面多了个&符号,你看会不会是这个的问题

之前是我的文本格式有问题,得出来的结果有错误

$json_string = $_GET["apply"];
 if(ini_get("magic_quotes_gpc")=="1")
 {
  $json_string=stripslashes($json_string);
 }

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板