What are the pre-defined variables for PHP?

Source: Internet
Author: User
Tags http authentication http cookie http digest authentication http file upload http post
"Super Global Variables"

A hyper-global variable is an internal variable that can always be used in all scopes. You do not need to perform global $variable in functions or methods, and you can access them.

"$GLOBALS"

  References all variables available in the global scope. is a globally combined array containing global variables whose names are the keys of the array.

"$_server"

An array that contains information such as header information, path, script location, and so on. The elements of the array are created by the Web server.

Php_self: The file name of the current execution script, which is related to document root. Such as: The address is Http://example.com/test/php/foo.bar script, $_server[' php_self ']= '/test.php/foo.bar '. (The file constant contains the full path and filename of the current document)

ARGV: An array of arguments passed to the script. When the script runs as a CLI, argv passes the command-line arguments to the program's C-language style. When called by the Get method, the change amount contains the query String.

ARGC: The number of scripts passed to script parameters in CLI run mode.

Gateway_interface: The version of the CGI specification used by the server. such as: "cgi/1.1".

SERVER_ADDR: The IP address of the server where the script is currently running.

SERVER_NAME: The host name of the server on which the script is currently running. If the script is running in a virtual host, the variable is determined by the value set by the virtual host.

Server_software: The server identification string, given in the header information of the response request.

Server_protocol: The name and version of the communication protocol when the page is requested. such as: "http/1.0".

Request_method: The method used to access the page. such as:, POST, PUT. (If the request method is head,php script will terminate after header header information, no output, no output buffering)

Request_time: Timestamp at the start of the request.

Query_string: query string. If so, make a page access through it.

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

Http_accept: The contents of the ACCEPT item in the current request header, if one exists.

Http_accept_charset: The contents of the Accept-charset item in the current request header, if one exists.

Http_accept_encoding: The contents of the Accept-encoding item in the current request, if one exists.

Http_accept_language: The contents of the Accept-language item in the current request, if one exists.

Http_connection: The contents of the CONNECTION item in the current request header, if one exists.

Http_host: The contents of the HOST item (if any) in the current request header.

Http_referer: The address (if any) that directs the user's agent to the previous page of the current page. Determined by the user agent settings. Not all users will set the item, and some also provide the ability to modify the Http_referer. Therefore, the value is not trustworthy.

Http_user_agent: The contents of the User-agent item in the current request header, if present. The string indicates the user agent information to access the page, such as: Mozilla/4.5[en] (X11; U Linux 2.2.9 i586). You can also use Get_browser () to get the value.

HTTPS: If the script is accessed through the HTTPS protocol, the value is set to a non-null value. When using ISAPI mode on IIS, this value will be off if it is not accessed through the HTTPS protocol.

REMOTE_ADDR: The IP address of the user browsing the current page.

Remote_host: The host name of the user who browsed the current page. DNS reverse resolution is not dependent on the user's remote_addr. The server must be configured to produce the variable, such as set hostnamelookups on in Apache.

Remote_port: The port number used by the user machine to connect to the Web server.

Script_filename: The absolute path of the current execution 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.

The port used by the Server_port:web server. The default is 80. If an SSL secure connection is used, the value is the HTTP port set by the user.

Server_signature: A string containing the server version and the hostname of the virtual machine.

Path_translated: The base path of 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.

The Request_uri:uri is used to specify which pages to access.

Php_auth_digest: When running as an Apache module, the amount of change is set to the "Authorization" HTTP header content sent by the client during HTTP DIGEST authentication.

Php_auth_user: When PHP is running under Apache or IIS modules and is using the HTTP authentication feature, the change amount is the user name entered by the user.

PHP_AUTH_PW: When PHP is running under the Apache or IIS module and is using the HTTP authentication feature, the change amount is the password that the user entered.

Auth_type: When PHP is running in the Apache module mode and is using the HTTP authentication feature, the change amount is the type of authentication.

Path_info: Contains the path information provided by the client, followed by the real script name and before the query statement, if present.

Orig_path_info: The original version of "Path_info" before being processed by PHP.

"$_get"

HTTP get variable.

An array containing the variables passed to the current script through the URL parameter.

Pass through UrlDecode ().

echo htmlspecialchars ($_get[' name ');

"$_post"

The HTTP post variable.

An array of variables passed to the current script through the HTTP POST method.

echo htmlspecialchars ($_post[' name ');

"$_files"

HTTP file upload variables.

An array of files uploaded to the current script via the HTTP POST method.

"$_request"

HTTP request variable.

An array of $_get,$_post,$_cookie is included by default.

Set the order of the GPC via PHP's Variables_order instruction or import_request_variables ().

"$_session"

Session variable.

"$_env"

Environment variables.

An array of variables passed to the current script through the environment. These variables are imported into the PHP global namespace by the PHP Parser runtime environment. Many are provided by a shell that supports PHP operations.

"$_cookie"

HTTP Cookies.

An array of variables passed to the current script by means of an HTTP cookie.

"$php _errormsg"

The previous error message.

$php _errormsg contains the latest error messages generated by PHP. The amount of change is only available within the scope of the error, and requires that the Track_errors configuration item is on (the default is off).

If the user defines an error handling handle (Set_error_handler ()) and returns False, the $php _errormsg is set.

"$HTTP _raw_post_data"

Native post data. Contains the original data for the post submission.

"$http _response_header"

HTTP response header.

Similar to Get_header (). When using the HTTP wrapper, the amount of change is populated with the HTTP response header information. The variable is created at the local scope.

"$ARGC"

The number of arguments passed to the script in CLI mode. Available only when REGISTER_ARGC_ARGV is open.

The script file name is always passed as a parameter to the current script.

"$ARGV"

An array of arguments passed to the script. Available only when REGISTER_ARGC_ARGV is open.

The first parameter is always the file name of the current script.

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.