Home >Backend Development >PHP Tutorial >PHP Task Learning 4: Understanding and Using PHP Super Global Variables_PHP Tutorial
Understand and use PHP super global variables
Super global variables are also called predefined variables. They are variables that come with the PHP system. They can make your programming more convenient and faster. Its types include:
$GLOBALS
Contains a reference to each variable that is valid in the global scope of the current script. The key names of this array are the names of global variables. The $GLOBALS array exists since 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 via URL requests.
$_POST
Variables submitted to the script via the HTTP POST method.
$_COOKIE
Variable submitted to the script via the HTTP Cookies method.
$_FILES
Variables submitted to the script via HTTP POST file upload.
$_ENV
Variables submitted by the execution environment to the script.
$_REQUEST
Variables submitted to the script via GET, POST and COOKIE mechanisms.
$_SESSION
The variable currently registered for the script session.
The specific information will not be explained one by one here. You can create a new PHP file and write the following code in the file.
and execute it, you can see the following screen:
In this page, you can view various types of super global variables that exist in the system, and you can also apply them.
The following 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:
Through the above examples, we found that predefined variables, that is, super global variables, do not need to be defined when used (you can query them through phpinfo), and they start with "$_", and the variable names are all capital letters, with "[ ]" enclose the corresponding parameters.
This is the end of our introduction to constant variables in PHP.
Reprinted from: http://www.cnblogs.com/walkbro/