doushih06137 2014-05-22 14:59
浏览 56
已采纳

当服务器有标签<head> </ head>时,询问服务器发送json和客户端接收器进程[php]不起作用?

please read before

Not duplicate with ask about server send json and client receiver for process [php] not work when server have condition e.g if else?

It's ok when i use this code.

send.php

{"text": "aaa","number": "111"}

receive.php

<?PHP
$url = "http://www.peveea.com/send.php";
$json = @file_get_contents($url, true);
$decode = json_decode($json, true);
$number = $decode[number];
echo $decode[number];
?>

but when i change send.php to this code (add tag haed) in receive.php not echo $decode[number];

<head>
<title>something</title>
<?head>
{"text": "aaa","number": "111"}
  • 写回答

2条回答 默认 最新

  • doulianqi3870 2014-05-22 15:01
    关注

    JSON is not HTML.

    You cannot have a <head> element in a JSON file.

    It makes the JSON invalid, so it cannot be parsed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗