Php learning notes pre-defined array (ultra-global array). For more information, see.
Php learning notes pre-defined array (ultra-global array). For more information, see.
-
-
- /* 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.
- }
- ?>
-
-
- // Directly use the passed value as a variable, which is useful when register_global = on is in the php. ini configuration file.
- Echo $ username ."
";
- Echo $ email ."
";
- Echo $ page ."
";
- // The most stable value method
- Echo $ _ GET ["username"]."
";
- Echo $ _ GET ["email"]."
";
- Echo $ _ GET ["page"]."
";
- ?>
- "Demo. php? Username = zhangsan & email = aaa@bbb.com & page = 45 "> this is a $ _ GET test
-
- "Demo. php" method = "post">
- Username: "Text" name = "uname"/>
- Password: "Password" name = "pass"/>
- "Submit" value = "login"/>
-
- Print_r ($ _ GET); // cannot receive
- Print_r ($ _ POST); // to receive
- ?>
-
- // $ _ ENV usage
- Echo'
';
- Print_r ($ _ ENV );
- Echo'
- ';
- // Display the current environment
- // You can also traverse
- ?>
-
- // 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"]."
";
- Echo $ GLOABLS ["B"]."
";
- Echo $ GLOABLS ["c"]."
";
- }
- ?>