Php study notes [pre-defined array (ultra-Global Array)]

Source: Internet
Author: User
Php learning notes pre-defined array (ultra-global array). For more information, see. The code is as follows:
/* 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"]."
";
?>
This is a $ _ GET test


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"]."
";
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.