PHP在不同页面间传递Json数据示例代码_php技巧
程序员文章站
2022-05-02 09:09:53
...
gettest.php文件:
$value["name"]= urlencode("我的姓名");
$value["pass"]= urlencode("pass888");
$value["age"]=30;
$jsonstr =json_encode($value);
$url="http://127.0.0.1:8080/get.php?id=100&value=$jsonstr";
$html = file_get_contents($url);
echo $html;
?>
get.php文件如下:
$x = json_decode(stripslashes ($_GET["value"]), true);
echo urldecode($x["name"]);
echo urldecode($x["pass"]);
?>
在IE中输入:http://127.0.0.1:8080/gettest.php
注意:gettest.php,get.php文件的格式utf-8格式。
复制代码 代码如下:
$value["name"]= urlencode("我的姓名");
$value["pass"]= urlencode("pass888");
$value["age"]=30;
$jsonstr =json_encode($value);
$url="http://127.0.0.1:8080/get.php?id=100&value=$jsonstr";
$html = file_get_contents($url);
echo $html;
?>
get.php文件如下:
复制代码 代码如下:
$x = json_decode(stripslashes ($_GET["value"]), true);
echo urldecode($x["name"]);
echo urldecode($x["pass"]);
?>
在IE中输入:http://127.0.0.1:8080/gettest.php
注意:gettest.php,get.php文件的格式utf-8格式。
上一篇: sql中对于传过来的空值判断,该怎么处理
下一篇: 深入php处理整数函数的详解_php技巧