php 通过get方式传递json

来源:互联网 发布:网络歌曲大全100首一 编辑:程序博客网 时间:2024/06/05 17:16

sender.php的代码如下

<?php/** * Created by PhpStorm. * User: gywtzh * Date: 2016/11/25 * Time: 11:58 */$arrorder = array ('orderid'=>'4','uid'=>'1','productnum'=>'2','productprice'=>'2.00','totalprice'=>'4.00',    'orderstate'=>'已付款','getcode'=>'1','gettime'=>'2016-11-01 00:00:00','productid'=>'123');$jsonorder =json_encode($arrorder, JSON_UNESCAPED_UNICODE);//JSON_UNESCAPED_UNICODE解决中文问题$url="http://localhost/receiever.php?jsonorder=$jsonorder";$html = file_get_contents($url);echo $html;?>
receiever.php的代码如下
<?php/** * Created by PhpStorm. * User: gywtzh * Date: 2016/11/25 * Time: 11:59 */$order = json_decode($_GET['jsonorder'], true);echo $order["orderid"];echo $order["productid"];?>
http://localhost/sender.php这样测试是没有效果的,原因在于get方式传递参数有长度限制,
如果去掉红色部分,再测试就可以取到值了
可以考虑用post方式传值

0 0