Home > Article > Backend Development > Predefined variables - PHP manual notes
Predefined variables represent all external variables as built-in environment variables, and error information as return headers. Superglobal variables are built-in variables that are always available in all scopes. They can be accessed within a function or method without executing global $variable
.
$GOBALS
refers to all variables available in the global scope, which are always available in PHP.
$_SERVER
Server and execution environment information, this contains more array elements, such as $_SERVER['PHP_SELFT']
, $_SERVER['SCRIPT_FILENAME']
, $_SERVER['SERVER_NAME']
, etc. . The items in this array are created by the web server, and every server is not guaranteed to serve all items.
$_GET
An array of variables passed to the current script via URL parameters.
$_POST
An array of variables passed to the current script via the HTTP POST method.
$_FILES
An array of files uploaded to the current script via HTTP POST.
$_REQUEST
By default, it contains arrays of $_GET
, $_POST
and $_COOKIE
. When running in command line mode, the argv
and argc
information will not be included, they will exist in the $_SERVER
array. The items of this array and their order depend on the configuration of PHP's variables_order
directive.
$_SESSION
The current script can use the array of SESSION variables to start a new session or reuse an existing session through session_start()
.
$_ENV
An array of variables passed to the current script through the environment. These variables are imported from the running environment of the PHP parser into the global namespace of PHP.
$_COOKIE
An array of variables passed to the current script through HTTP Cookies. Cookies can be set on the client through setcookie()
.
$php_errormsg
Contains the latest error message generated by PHP and is only available in the scope where the error occurred.
$HTTP_RAW_POST_DATA
Contains the raw data submitted by POST.
$http_response_header
contains the HTTP response header. Why was the test not successful in my system?
$argc
contains the number of arguments passed to the current script when running from the command line. The minimum value is 1. Only available when regiser_argc_argv
is turned on.
$argv
contains an array of arguments passed to the current script when running from the command line. The first argument is always the filename of the current script.
(Full text ends)
The above introduces the predefined variables - PHP manual notes, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.