Understand and use PHP Super global variables. Understanding and Using PHP Super global variable is also called pre-defined variable. it is a self-contained variable in the PHP System, which makes your program design more convenient and fast. Its types include understanding and using PHP Super global variables
Super global variables are also called pre-defined variables. they are self-contained variables in the PHP System. they make your program design more convenient and convenient. Its types include:
$ GLOBALS
Contains a reference to a variable that is valid globally for each current script. The key name of the array is the name of the global variable. $ GLOBALS array exists from 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
Variables submitted to the script through URL requests.
$ _ POST
Variables submitted to the script through the http post method.
$ _ COOKIE
Variables submitted to the script through HTTP Cookies.
$ _ FILES
Variables submitted to the script by uploading the http post file.
$ _ ENV
Variables submitted to the script in the execution environment.
$ _ REQUEST
Variables submitted to the script through GET, POST, and COOKIE mechanisms.
$ _ SESSION
The variable currently registered to the script session.
The specific information is not explained here. you can create a php file and write the following code in the file.
The code is as follows:
Phpinfo ();
?>
And then you can see the following picture
On this page, you can view various types of super global variables in the system and apply them.
The following example shows how to use a php file to display the current file and the IP address of the current server.
The code is as follows:
The code is as follows:
Echo "the current file is". $ _ SERVER ["PHP_SELF"];
Echo"
";
Echo "the IP address of the current SERVER is:". $ _ SERVER ["SERVER_ADDR"];
?>
Through the above example, we found that the pre-defined variable, that is, the Super global variable, does not need to be defined during use (you can use phpinfo to query) and starts with "$, the variable names are all uppercase letters, and the corresponding parameters are enclosed in.
At this point, we will end the introduction of constant variables in PHP.
Magio's school is approaching the final exam, and it is estimated that the updates in the next few days will not be too timely. Sorry!
The extra super global variable is also called a predefined variable. it is a self-contained variable in the PHP System. it makes your program design more convenient and convenient. Its types include...