PHP pre-defined variable _php

Source: Internet
Author: User
Keywords variable definition use Global script Automatic PHP one all letter
Tags http authentication http file upload
Pre-defined variables
Server variable: $_server
Note: Used in PHP 4.1.0 and later versions. Previous versions, using the $HTTP _server_vars.

$_server is an array that contains such things as the head (headers), Path (paths), and script location (scripts locations). The entity of the array is created by the Web server. There is no guarantee that all servers will generate all the information; the server may have ignored some information or generated some new information that is not listed below. This means that a large number of these variables are described in CGI 1.1 specification, so you should study it carefully.

This is a "superglobal", or can be described as an automatic global variable. This simply means that it works in all scripts. You do not need to use the global $_server in a function or method; Access it as if you were using a $HTTP _server_vars.

$HTTP _server_vars contains the same information, but not an automatic global variable. (Note: $HTTP _server_vars and $_server are different variables, and PHP handles them in different ways.) )

If the register_globals directive is set, these variables are also available in all scripts, that is, the $_server and $HTTP _server_vars arrays are separated. For related information, please refer to the section on security using Register Globals. These individual global variables are not automatic global variables.

You may find that some of the $_server elements listed below are not available. Note that if you run PHP as a command line, the elements listed below are almost no valid (or meaningless).



"Php_self"
The file name of the currently executing script, which is related to document root. For example, using $_server[' php_self ' in a script with a URL address of Http://example.com/test.php/foo.bar will give the result/test.php/foo.bar.

If PHP is running as a command line, the variable is not valid.

"ARGV"
The arguments passed to the script. When the script runs in command-line mode, the ARGV variable is passed to the program's C-language style command-line arguments. When the GET method is called, the variable contains the requested data.

"ARGC"
Contains the number of command-line arguments passed to the program (if run in command-line mode).

"Gateway_interface"
The version of the CGI specification used by the server. For example, "cgi/1.1".

' Server_Name '
The name of the server host where the script is currently running. If the script is running on a virtual host, the name is determined by the value set by that virtual host.

' Server_software '
The string that the server identifies is given in the header in response to the request.

"Server_protocol"
The name and version of the communication protocol when the page is requested. For example, "http/1.0".

"Request_method"
The request method when the page is accessed. For example:, POST, PUT.

"Query_string"
A string that queries (query).

"Document_root"
The document root directory where the script is currently running. Defined in the server configuration file.

"Http_accept"
Accept for current request: The contents of the header.

"Http_accept_charset"
Accept-charset of the current request: the contents of the header. For example: "Iso-8859-1,*,utf-8".

"Http_accept_encoding"
Accept-encoding of the current request: the contents of the header. For example: "gzip".

"Http_accept_language"
Accept-language of the current request: the contents of the header. For example: "en".

"Http_connection"
Connection of the current request: the contents of the header. For example: "Keep-alive".

"Http_host"
Host of the current request: the contents of the header.

"Http_referer"
The URL address of the previous page that links to the current page. Not all user agents (browsers) will set this variable, and some can manually modify the Http_referer. Therefore, this variable is not always correct and true.

"Http_user_agent"
User_agent of the current request: the contents of the header. The string indicates the information of the user agent accessing the page. A typical example is: mozilla/4.5 [en] (X11; U Linux 2.2.9 i586). You can also use Get_browser () to get this information.

"REMOTE_ADDR"
The IP address of the user who is browsing the current page.

"Remote_port"
The port that the user uses when connecting to the server.

"Script_filename"
The absolute path name of the currently executing script.

"Server_admin"
This value indicates the Server_admin parameter in the Apache server configuration file. If the script is running on a virtual host, the value is the value of that virtual host.

"Server_port"
The port used by the server. The default is "80". If you are using an SSL secure connection, this value is the HTTP port you set.

"Server_signature"
A string containing the server version and the virtual host name.

"Path_translated"
The base path to the file system (not the document root) where the current script resides. This is the result of the server making a virtual-to-real-path image.

"Script_name"
Contains the path to the current script. This is useful when the page needs to point to itself.

"Request_uri"
The URI required to access this page. For example, "/index.html".

"Php_auth_user"
When PHP is running in the Apache module mode and is using the HTTP authentication feature, this variable is the user name entered by the user.

"PHP_AUTH_PW"
When PHP is running in the Apache module mode and is using the HTTP authentication function, this variable is the password entered by the user.

"Php_auth_type"
This variable is the type of authentication when PHP is running in the Apache module mode and is using the HTTP authentication feature.


Environment variable: $_env
Note: Used in PHP 4.1.0 and later versions. Previous versions, using the $HTTP _env_vars.

When the parser runs, these variables change from environment variables to PHP global variable Namespaces (namespace). Many of them are determined by the system that PHP runs. A complete list is not possible. Please review your system's documentation to determine its specific environment variables.

Other environment variables, including CGI variables, are listed here, regardless of whether PHP is run as a server module or as a CGI processing.

This is a "superglobal", or can be described as an automatic global variable. This simply means that it works in all scripts. You do not need to use the global $_env in a function or method; To access it, just as with $HTTP _env_vars.

$HTTP _env_vars contains the same information, but not an automatic global variable. (Note: Http_env_vars and $_env are different variables, and PHP handles them in different ways.) )

If the register_globals directive is set, these variables are also available in all scripts, that is, the $_env and $HTTP _env_vars arrays are separated. For related information, please refer to the section on security using Register Globals. These individual global variables are not automatic global variables.

HTTP Cookies:$_cookie
Note: Used in PHP 4.1.0 and later versions. Previous versions, using the $HTTP _cookie_vars.

An array of variables that are passed through HTTP cookies. is an automatic global variable.

This is a "superglobal", or can be described as an automatic global variable. This simply means that it works in all scripts. You do not need to use the global $_cookie in a function or method; To access it, just as with $HTTP _cookie_vars.

$HTTP _cookie_vars contains the same information, but not an automatic global variable. (Note: Http_cookie_vars and $_cookie are different variables, and PHP handles them in different ways.) )

If the register_globals directive is set, these variables are also available in all scripts, that is, the $_cookie and $HTTP _cookie_vars arrays are separated. For related information, please refer to the section on security using Register Globals. These individual global variables are not automatic global variables.

HTTP GET Variable: $_get
Note: Used in PHP 4.1.0 and later versions. Previous versions, using the $HTTP _get_vars.

An array of variables passed through the HTTP GET method. is an automatic global variable.

This is a "superglobal", or can be described as an automatic global variable. This simply means that it works in all scripts. You do not need to use the global $_get in a function or method; To access it, just as with $HTTP _get_vars.

$HTTP _get_vars contains the same information, but not an automatic global variable. (Note: Http_get_vars and $_get are different variables, and PHP handles them in different ways.) )

If the register_globals directive is set, these variables are also available in all scripts, that is, the $_get and $HTTP _get_vars arrays are separated. For related information, please refer to the section on security using Register Globals. These individual global variables are not automatic global variables.

HTTP POST Variable: $_post
Note: Used in PHP 4.1.0 and later versions. Previous versions, using the $HTTP _post_vars.

An array of variables that are passed through the HTTP POST method. is an automatic global variable.

This is a "superglobal", or can be described as an automatic global variable. This simply means that it works in all scripts. You do not need to use the global $_post in a function or method; To access it, just as with $HTTP _post_vars.

$HTTP _post_vars contains the same information, but not an automatic global variable. (Note: Http_post_vars and $_post are different variables, and PHP handles them in different ways.) )

If the register_globals directive is set, these variables are also available in all scripts, that is, the $_post and $HTTP _post_vars arrays are separated. For related information, please refer to the section on security using Register Globals. These individual global variables are not automatic global variables.

HTTP File Upload variable: $_files
Note: Used in PHP 4.1.0 and later versions. Previous versions, using the $HTTP _post_files.

An array of uploaded file items that are passed through the HTTP POST method. is an automatic global variable.

This is a "superglobal", or can be described as an automatic global variable. This simply means that it works in all scripts. You do not need to use the global $_files in a function or method; To access it, just as with $HTTP _post_files.

$HTTP _post_files contains the same information, but not an automatic global variable.

If the register_globals directive is set, these variables are also available in all scripts, that is, the $_files and $HTTP _post_files arrays are separated. For related information, please refer to the section on security using Register Globals. These individual global variables are not automatic global variables.

Request variable: $_request
Note: Used in PHP 4.1.0 and later versions. The previous version, there is no equivalent array.

An array of all the contents consisting of $_get,$_post and $_cookie.

Note: $_files is also included in the $_request array before PHP 4.3.0.

This is a "superglobal", or can be described as an automatic global variable. This simply means that it works in all scripts. You do not need to use the global $_request in a function or method; To access it.

If the register_globals directive is set, these variables are also available in all scripts, that is, the $_request array is detached. For related information, please refer to the section on security using Register Globals. These individual global variables are not automatic global variables.

Session variable: $_session
Note: Used in PHP 4.1.0 and later versions. Previous versions, using the $HTTP _session_vars.

An array containing the session variables in the current script. See the Session function documentation for more information.

This is a "superglobal", or can be described as an automatic global variable. This simply means that it works in all scripts. You do not need to use the global $_session in a function or method; To access it, just as with $HTTP _session_vars.

$HTTP _session_vars contains the same information, but not an automatic global variable.

If the register_globals directive is set, these variables are also available in all scripts, that is, the $_session and $HTTP _session_vars arrays are separated. For related information, please refer to the section on security using Register Globals. These individual global variables are not automatic global variables.

Global variable: $GLOBALS
Note: The $GLOBALS is applicable in PHP 3.0.0 and later versions.

An array that consists of all defined global variables. The variable name is the index of the array.

This is a "superglobal", or can be described as an automatic global variable. This simply means that it works in all scripts. You do not need to use the global $GLOBALS in a function or method; To access it.

Previous error message: $php _errormsg
$php _errormsg is a variable that contains the content of the last error message generated by PHP. The variable is not valid until an error occurs and the Track_errors option is turned on (off by default).
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.