In PHP4.2 and later versions, register_global defaults to off
If you want to get the variables submitted from another page:
Method 1: Find it in PHP.ini register_global, and set it to on.
Method 2: Put this extract($_POST);extract($_GET); at the front of the receiving web page (note that there must be Session_Start() before extract($_SESSION)) .
Method 3: Read variables $a=$_GET["a"];$b=$_POST["b"], etc. one by one. Although this method is troublesome, it is safer.
<font color="#000000"><code><font color="#000000"><br><font face="新宋体" color="#0000bb"><?PHP <br>Ob_Start</font><font face="新宋体"><font color="#007700">();<br></font><font color="#0000bb">Session_Start</font></font><font face="新宋体"><font color="#007700">();<br>Echo </font><font color="#dd0000">"<div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">"</pre><div class="contentsignin">Copy after login</div></div></font></font><font face="新宋体"><font color="#007700">;<br>Echo </font><font color="#dd0000">"本页得到的_GET变量有:"</font></font><font face="新宋体"><font color="#007700">;<br></font><font color="#0000bb">Print_R</font><font color="#007700">(</font><font color="#0000bb">$_GET</font></font><font face="新宋体"><font color="#007700">);<br>Echo </font><font color="#dd0000">"本页得到的_POST变量有:"</font></font><font face="新宋体"><font color="#007700">;<br></font><font color="#0000bb">Print_R</font><font color="#007700">(</font><font color="#0000bb">$_POST</font></font><font face="新宋体"><font color="#007700">);<br>Echo </font><font color="#dd0000">"本页得到的_COOKIE变量有:"</font></font><font face="新宋体"><font color="#007700">;<br></font><font color="#0000bb">Print_R</font><font color="#007700">(</font><font color="#0000bb">$_COOKIE</font></font><font face="新宋体"><font color="#007700">);<br>Echo </font><font color="#dd0000">"本页得到的_SESSION变量有:"</font></font><font face="新宋体"><font color="#007700">;<br></font><font color="#0000bb">Print_R</font><font color="#007700">(</font><font color="#0000bb">$_SESSION</font></font><font face="新宋体"><font color="#007700">);<br>Echo </font><font color="#dd0000">""</font></font><font face="新宋体" color="#007700">;<br></font><font face="新宋体" color="#0000bb">?><br></font></font><br>
Ob_Start();Echo();PHP代码:<font color="#000000"><br><font color="#0000bb"><?php <br>$Var</font><font color="#007700">=</font><font color="#dd0000">"hello php"</font><font color="#007700">;</font><font color="#ff8000">//修改为$Var=" hello php";试试得到什么结果<br></font><font color="#0000bb">$post</font><font color="#007700">= </font><font color="#dd0000">"receive.php?Name="</font><font color="#007700">.</font><font color="#0000bb">$Var</font><font color="#007700">;<br></font><font color="#0000bb">header</font><font color="#007700">(</font><font color="#dd0000">"location:$post"</font><font color="#007700">);<br></font><font color="#0000bb">?><br></font></font>
Copy after login
""
;
PHP代码:<font color="#000000"><br><font color="#0000bb"><?PHP <br></font><font color="#007700">Echo </font><font color="#dd0000">"<div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">"</pre><div class="contentsignin">Copy after login</div></div></font><font color="#007700">;<br>Echo </font><font color="#0000bb">$_GET</font><font color="#007700">[</font><font color="#dd0000">"Name"</font><font color="#007700">];<br>Echo </font><font color="#dd0000">"</font></font>
Contents of receive.php:
"PHP代码:<font color="#000000"><br><font color="#0000bb"><?php <br>$Var</font><font color="#007700">=</font><font color="#dd0000">"hello php"</font><font color="#007700">;<br></font><font color="#0000bb">$post</font><font color="#007700">= </font><font color="#dd0000">"receive.php?Name="</font><font color="#007700">.</font><font color="#0000bb">urlencode</font><font color="#007700">(</font><font color="#0000bb">$Var</font><font color="#007700">);<br></font><font color="#0000bb">header</font><font color="#007700">(</font><font color="#dd0000">"location:$post"</font><font color="#007700">);<br></font><font color="#0000bb">?><br></font></font>
Copy after login
;
The correct way is: