首頁  >  文章  >  後端開發  >  PHP在不同页面间传递Json数据示例代码_PHP教程

PHP在不同页面间传递Json数据示例代码_PHP教程

WBOY
WBOY原創
2016-07-21 15:07:261070瀏覽

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格式。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/327538.htmlTechArticlegettest.php文件: 复制代码 代码如下: ?php $value["name"]= urlencode("我的姓名"); $value["pass"]= urlencode("pass888"); $value["age"]=30; $jsonstr =json_encode($value...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn