Copy codeThe Code is as follows:
<? Php
/* Pre-defined array:
* Automatic global variable --- super Global Array
*
* 1. contains data from WEB servers, clients, runtime environments, and user input.
* 2. These arrays are special.
* 3. These arrays can be used directly if they take effect automatically within the global range.
* 4. Users cannot customize these arrays, but these arrays are operated in the same way as their own arrays.
* 5. You can directly use these arrays in functions.
*
* $ _ GET // variable submitted to the script through URL request
* $ _ POST // variables submitted to the script through the http post method
* $ _ REQUEST // variables submitted to the script through GET, POST, and COOKIE mechanisms
* $ _ FILES // variables submitted to the script by uploading FILES via the http post method
* $ _ COOKIE
* $ _ SESSION
* $ _ ENV // variables submitted to the script in the execution environment
* $ _ SERVER // The variable is set by the web server or directly associated with the execution environment of the current script.
* $ GLOBALS // as long as the variables are valid for the current script, the array key name is the name of the global script.
*
*
*/
// The Super global array can be directly called within the function.
$ Arr = array (10, 20); // a general array
$ _ GET = array (50, 90); // a super Global array
Function demo (){
Global $ arr; // You must include
Print_r ($ arr );
Print_r ($ _ GET); // you do not need to include a directly called Ultra-Global Array.
}
?>
<! -- *************************** -->
<? Php
// Directly use the passed value as a variable, which is useful when register_global = on is in the php. ini configuration file.
Echo $ username. "<br> ";
Echo $ email. "<br> ";
Echo $ page. "<br> ";
// The most stable value 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>
<! -- ***************************** -->
<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); // cannot receive
Print_r ($ _ POST); // to receive
?>
<? Php
// $ _ ENV usage
Echo '<pre> ';
Print_r ($ _ ENV );
Echo '</pre> ';
// Display the current environment
// You can also traverse
?>
<? Php
// Use the $ GLOBALS ultra-Global Array to call global variables within the Function
$ A = 100;
$ B = 200;
$ C = 300;
Function demo ()
{
// Directly call global variables
Echo $ GLOBALS ["a"]. "<br> ";
Echo $ GLOABLS ["B"]. "<br> ";
Echo $ GLOABLS ["c"]. "<br> ";
}
?>