PHP passes sample Json data between pages

  • 2020-06-12 08:36:30
  • OfStack

gettest. php file:
 
<?php 
$value["name"]= urlencode(" My name "); 
$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 file is as follows:
 
<?php 
$x = json_decode(stripslashes ($_GET["value"]), true); 
echo urldecode($x["name"]); 
echo urldecode($x["pass"]); 
?> 

Input: in IE http: / / 127.0.0.1:8080 / gettest. php

Note: gettest. php, get. php file format utf-8 format.

Related articles: