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.
Copy the code The code is as follows:
phpinfo();
?>
Copy the code 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"];
?>
The above introduces how to define global variables, understand and use PHP super global variables, including the content of defining global variables. I hope it will be helpful to friends who are interested in PHP tutorials.