Home > Article > Backend Development > What is the super global variable in php
In PHP, superglobal variables were introduced in "PHP4.1" and are built-in variables that are always available in all scopes. Superglobal variables can be accessed from any function, class, or any file without performing any special task like declaring any global variables; they are mainly used to store and retrieve information from one page to another in the application.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
What is Superglobals? variable?
Superglobal variables are built-in variables introduced in PHP4.1 that are always available in all scopes. Superglobal variables can be accessed within a function or method without using the global keyword.
They can use super global variables to access information at any time and anywhere in the script. That is, regardless of the scope, information about the request or its context can be easily obtained.
Super global variables can be accessed from any function, class or any file without performing any special task like declaring any global variable etc. They are mainly used to store and retrieve information from one page to another in the application.
Extension:
There are many superglobal variables in PHP, which means that they are available in the entire scope of a script. They can be accessed within a function or method without executing global $variable;.
These superglobal variables are:
$GLOBALS: refers to all variables available in the global scope. A global combined array containing all variables. The name of the variable is the key of the array.
$_SERVER: An array containing information such as header, path, and script location. The items in this array are created by the web server. There is no guarantee that every server will offer all items; servers may ignore some, or serve items not listed here.
$_GET: HTTP GET variables, an array of variables passed to the current script through URL parameters.
$_POST: HTTP POST variable. When the Content-Type of the HTTP POST request is application/x-www-form-urlencoded or multipart/form-data, the variable will be associated with Pass the current script in array form.
$_FILES: HTTP file upload variable, an array of items uploaded to the current script through HTTP POST.
$_COOKIE: HTTP Cookies, an array of variables passed to the current script through HTTP Cookies.
#$_SESSION: Session variable, an array of SESSION variables available in the current script.
$_REQUEST: HTTP Request variable, which by default contains arrays of $_GET, $_POST and $_COOKIE. $_FILES information has been removed from $_REQUEST since PHP 4.1.
#$_ENV: Environment variable, an array of variables passed to the current script through the environment. These variables are imported from the PHP parser's runtime environment into PHP's global namespace. Many are provided by shells that support PHP running, and different systems are likely to run different kinds of shells, so a definitive list is impossible.
For more related knowledge, please visit PHP Chinese website! !
The above is the detailed content of What is the super global variable in php. For more information, please follow other related articles on the PHP Chinese website!