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 the Code code as follows:
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 the Code code as follows:
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.
Megara's school is nearing the end of the final exam, and the next few days are expected to be less than timely. I hope you forgive me!
The above describes the definition of global variables and the use of PHP super global variables, including the definition of global variables, I hope that the PHP tutorial interested in a friend helpful.