Copy Code code as follows:
<?php
/* Predefined arrays:
* AUTO global variable---Super global array
*
* 1. Contains data from Web server, client, running environment and user input
* 2. These arrays are more specific
* 3. The global scope automatically takes effect, you can use these arrays directly
* 4. Users cannot customize these arrays, but these arrays operate in the same way as the array operations they define
* 5. These arrays can be used directly in functions
*
* $_get//variable submitted to script via URL request
* $_post//variable submitted to script via HTTP POST method
* $_request//variable submitted to script via get, post and cookie mechanism
* $_files//variable submitted to script via HTTP POST method file upload
* $_cookie
* $_session
* $_env//Execution Environment submitted to script variables
* $_server//variables are set by the Web server or are directly associated with the execution environment of the current script
* $GLOBALS//As long as the current script valid variables are here, the array's key name is the name of the global script
*
*
*/
A super global array can be called directly inside a function
$arr =array (10,20);//General array
$_get=array (50,90);//Super Global array
Function Demo () {
The global $arr;//Calling globally variable to include first
Print_r ($arr);
Print_r ($_get);//Direct call to a super global array without including
}
?>
<!--********** Page pass value GET request ***************-->
<?php
Direct transfer of the value variable used, when the php.ini configuration file Register_global=on useful.
echo $username. " <br> ";
echo $email. " <br> ";
echo $page. " <br> ";
The most stable value-taking method
echo $_get["username"]. " <br> ";
echo $_get["email"]. " <br> ";
echo $_get["page"]. " <br> ";
?>
<a href= "demo.php?username=zhangsan&email=aaa@bbb.com&page=45" >this is a $_GET test</a>
<!--*********** page Transfer value POST request ****************-->
<form action= "demo.php" method= "POST" >
Username:<input type= "text" name= "uname"/> <br/>
Password:<input type= "password" name= "pass"/> <br/>
<input type= "Submit" value= "login"/> <br/>
</form>
<?php
Print_r ($_get);/Not Received
Print_r ($_post);//So that you can receive
?>
<?php
The use of $_env
Echo ' <pre> ';
Print_r ($_ENV);
Echo ' </pre> ';
Show Current environment
You can also traverse a single
?>
<?php
Calling global variables inside a function using a $globals hyper-global Array
$a = 100;
$b = 200;
$c = 300;
Function Demo ()
{
Calling global variables directly
echo $GLOBALS ["a"]. " <br> ";
echo $GLOABLS ["B"]. " <br> ";
echo $GLOABLS ["C"]. " <br> ";
}
?>