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

yipeiwu_com6年前PHP代码库
gettest.php文件:
复制代码 代码如下:

<?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文件如下:
复制代码 代码如下:

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

相关文章

用PHP的ob_start();控制您的浏览器cache!

【转载】原文地址:http://www.itbbs.cn/index.php?showtopic=1074    Output Control 函数可以让你自由控制脚...

PHP中实现接收多个name相同但Value不相同表单数据实例

最近在一个询盘留言管理系统时候一个问题,留言的前台的表单当中出现很多name值相同的input框,这些框是由用户填写的各不相同的值,现在要迁移到php平台上,而且要求不能改变前台的任何表...

PHP实现下载功能的代码

wzskynet#163.com ·php escapeshellcmd多字节编码漏洞 ·详细讲解PHP中缓存技术的应用 ·利用PHP V5开发多任务应用程序 ·详细解析 PHP 向 M...

coreseek 搜索英文的问题详解

问题描述: 被搜索名字为:andy 这时搜索andy正常,但是搜索a就搜不到。 解决办法,在索引配置文件中的index中添加min_infix_len = 1最后还要重新索引一下/usr...

php常用字符串输出方法分析(echo,print,printf及sprintf) 原创

本文讲述了php常用字符串输出方法。分享给大家共大家参考,具体如下: 1. echo用法:可用echo 直接输出,也可以用echo()输出,无返回值 $string="<b&g...