What are PHP predefined variables?
In PHP programming, you often encounter information that requires the use of the address bar, such as domain names, visited URLs, URL parameters, etc. In this case, you can use the predefined variables provided by PHP , through these predefined variables, information such as the user's session, the user's operating system environment and the local operating system environment can be obtained. This information is stored in the predefined variable $_SERVER. (Detailed explanation of PHP predefined constant examples)
The predefined variable $_SERVER
##$_SERVER is a variable that contains information such as An array of header information (header), path (path), and script locations (script locations) and other information. Now I will print $_SERVE to see the content of $_SERVER. The code is as follows;
<?php echo "<pre class="brush:php;toolbar:false">"; print_r($_SERVER); ?>
php super global variables.
What are the predefined variables in php?
The following table is some commonly used predefined variables in PHP. The first few in the table are some information in $_SERVER. If you are interested, you can take a look at the above exampleName of the variable | Description |
$_SERVER['SERVER_ADDR'] | Currently running script The IP address of the server |
$_SERVER['SERVER_NAME'] | The host name of the server where the script is currently running. If the program is running on a virtual host, the name is determined by the value set by the virtual host |
$_SERVER['REQUERT_METHOD'] | The request method used to access the page. Such as GET, HEAD, POST, PUT, etc., if the request method is HEAD, the PHP script will output the header information and then terminate (this means that after any output is generated, there will be no output buffering) |
$_SERVER['REMOTE_ADDR'] | The IP address of the user browsing the current page |
Browse The host name of the user on the current page. Reverse domain name resolution is based on the user's REMOTE_ADDR | |
The user's machine is connected to the Web server Port number used | |
The absolute path of the currently executing script. Note that if the script is executed from the CLI as a relative path, such as file.php or .../file.php, $_SERVER['SCRIPT_FILENAME'] will contain the user-specified relative path | |
The port number of the server where the script is currently running, the default is 80. If an SSL secure connection is used, this value is the HTTP port set by the user | |
A string containing the server version and virtual host name. | |
The document root directory where the currently running script is located. Defined in the server configuration file. | |
An array of variables passed to the current script through HTTP Cookies. Most of these cookies are set through the setCookies() function when executing PHP scripts. | |
Contains information related to all session variables. The $_SESSION variable is mainly used for session control and the transfer of values between pages | |
Contains information related to parameters passed through the POST method, mainly used to obtain data submitted through the POST method | |
Contains information related to parameters passed through the GET method, mainly used to obtain data submitted through the GET method | |
is defined by all An array of global variables. The variable name is the index into the array. It can be said to be a super set of all super variables. | |
Array of items uploaded to the current script via HTTP POST | |
Contains arrays of $_GET, $_POST and $_COOKIE by default. | |
An array of variables passed to the current script through the environment. | |
Previous error message | |
Native POST data | |
HTTP response header | |
The number of parameters passed to the script | |
Argument array passed to the script |
The above is the detailed content of Detailed explanation of PHP predefined variable examples. For more information, please follow other related articles on the PHP Chinese website!