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

时间:2022-10-16 19:14:03
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格式给接下出来呢?

11 个解决方案

#1


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

#2


引用 1 楼  的回复:
$x = json_decode($_GET['apply']);

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

#3


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

#4


引用 3 楼  的回复:
var_dump(json_decode($_GET['apply'],true));
看輸出什麽?

NULL

#5


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

#6


引用 5 楼  的回复:
var_dump(json_decode(urldecode($_GET['apply']),true));


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

#7


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
        )

)

#8


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


嗯,谢谢了

#9


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

#10


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

#11


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

#1


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

#2


引用 1 楼  的回复:
$x = json_decode($_GET['apply']);

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

#3


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

#4


引用 3 楼  的回复:
var_dump(json_decode($_GET['apply'],true));
看輸出什麽?

NULL

#5


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

#6


引用 5 楼  的回复:
var_dump(json_decode(urldecode($_GET['apply']),true));


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

#7


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
        )

)

#8


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


嗯,谢谢了

#9


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

#10


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

#11


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