欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

PHP在不同页面间传递Json数据示例

程序员文章站 2022-05-31 17:58:40
...
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"]);
?>