Recognize and use PHP Super global variables
The super global variable, also known as a predefined variable, is a self-contained variable in the PHP system, which makes your programming easier and faster. The types of this include:
$GLOBALS
Contains a reference to a globally valid variable that refers to each current script. The key name of the array is the name of the global variable. $GLOBALS array exists starting with PHP 3.
$_server
Variables are set by the Web server or directly associated with the execution environment of the current script. Similar to the old array
$_get
A variable that is submitted to the script via a URL request.
$_post
A variable that is submitted to the script via the HTTP POST method.
$_cookie
A variable that is submitted to the script via the HTTP cookie method.
$_files
A variable that is submitted to the script via an HTTP POST file upload.
$_env
Executes the variables that the environment submits to the script.
$_request
Variables that are submitted to the script via the Get,post and COOKIE mechanisms.
$_session
The variable currently registered to the script session.
Specifically, this information is not explained here, you can create a new PHP file, write the following code in the file.
Copy to ClipboardWhat to refer to: [www.bkjia.com] Phpinfo ()
?>
And execute, you can see the following screen:
In this page, you can see the various types of super global variables that exist in the system, so you can also apply it.
Here is an example of using a PHP file to display the current file and the IP address of the current server.
The code is as follows:
Copy to ClipboardWhat to refer to: [www.bkjia.com] echo "Current file is". $_server["Php_self"];
echo "
";
echo "The IP address of the current server is:". $_server["Server_addr"];
?>
From the above example, we find that the predefined variables, which are super global variables, are not defined when they are used (you can query by Phpinfo), and begin with "$_", the variable names are uppercase letters, and the corresponding parameters are enclosed with "[]".
Here, we're done with the constant variables in PHP.
Transferred from: http://www.cnblogs.com/walkbro/
http://www.bkjia.com/PHPjc/364488.html www.bkjia.com true http://www.bkjia.com/PHPjc/364488.html techarticle recognizing and using the PHP Super global variable Super global variable is also called a predefined variable, which is the variable that comes with the PHP system, which can make your programming easier and quicker. Its types include ...