Home > php教程 > php手册 > PHP在不同页面间传递Json数据示例代码

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

WBOY
Release: 2016-06-06 20:31:24
Original
977 people have browsed it

本文为大家介绍下PHP如何在不同页面间传递Json数据,具体实现如下,感兴趣的朋友可以参考下哈,希望对大家有所帮助

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中输入::8080/gettest.php

注意:gettest.php,服务器空间,香港空间,get.php文件的格式utf-8格式。 ,服务器空间
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template