php使用Url读取文件的内容及file_get_contents用法

来源:互联网 发布:网络新媒体概论微盘 编辑:程序博客网 时间:2024/06/06 01:54


#########test1.php###############

<?php

$value["name"] = urlencode("我的姓名");
$value["pass"] = urldecode("pass888");
$value["age"] = 30;


$jsonstr = json_encode($value);
//$url="http://127.0.0.1/view/test2.php?id=100&value=$jsonstr";
$url="http://www.baidu.com";
$html = file_get_contents($url);
echo $html;

?>


#############127.0.0.1/view/test2.php#####################

<?php

$x = json_decode(stripslashes ($_GET["value"]), true);   
echo urldecode($x["name"]);   
echo urldecode($x["pass"]);
echo urldecode($x["age"]);

?>