getenv function _php Tutorial in PHP

Source: Internet
Author: User
Tags http authentication http digest authentication
In PHP, the getenv (parameter) function is a function to get environment variables, depending on the parameters available to obtain different environment variables, as follows:

"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 [Url]http://example.com/test.php/foo.bar[/url] will give the result/test.php/foo.bar. The __FILE__ constant contains the absolute path and file name of the current (for example, the containing) file.

If PHP is run as a command line, the variable is not valid until PHP 4.3.0.

"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 information 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.

Note: If the request is in the way that the head,php script will abort after the message is sent out (this means that no output buffers are available after any output has been generated).

"Request_time"

Timestamp at the start of the request. Valid from PHP 5.1.0.

"Query_string"

(query) string (the first question mark in the URL?) After the content).

"Document_root"

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

"Http_accept"

Accept: The contents of the header information for the current request.

"Http_accept_charset"

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

"Http_accept_encoding"

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

"Http_accept_language"

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

"Http_connection"

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

"Http_host"

Host of the current request: the contents of the header information.

"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 true and correct.

"Http_user_agent"

User-agent of the current request: the contents of the header information. 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.

"HTTPS"

If the script is accessed through the HTTPS protocol, it is set to a non-null value.

"REMOTE_ADDR"

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

"Remote_host"

The host name of the user who is browsing the current page. Reverse Domain name resolution is based on the user's remote_addr.

Note: The Web server must be configured to establish this variable. For example, Apache needs to have hostnamelookups on in httpd.conf. See Gethostbyaddr ().

"Remote_port"

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

"Script_filename"

The absolute path name of the currently executing script.

Note: If the script is executed in the CLI as a relative path, such as file.php or. /file.php,$_server[' Script_filename ' will contain the user-specified relative path.

"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 SSL secured connection is used, this value is the HTTP port set by the user.

"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.

Note: After PHP 4.3.2, path_translated is no longer implicitly assigned in Apache 2 SAPI mode, but if Apache does not generate this value, PHP generates it itself and puts its value in the Script_filename server constant 。 This modification complies with the CGI specification, and path_translated exists only under the conditions defined by PATH_INFO.

Apache 2 users can use Acceptpathinfo on in httpd.conf to define PATH_INFO.

"Script_name"

Contains the path to the current script. This is useful when the page needs to point to itself. __FILE__ contains the absolute path and file name of the current file (for example, include files).

"Request_uri"

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

"Php_auth_digest"

When running as an Apache module, during HTTP Digest authentication, this variable is set to the "Authorization" HTTP header content sent by the client (for further authentication operations).

"Php_auth_user"

When PHP is running in Apache or IIS (PHP 5 is an ISAPI) module, and the HTTP authentication feature is being used, this variable is the user name entered by the user.

"PHP_AUTH_PW"

When PHP is running in Apache or IIS (PHP 5 is an ISAPI) module, and the HTTP authentication feature is being used, this variable is the password that the user entered.

This article is from the "WebOS" blog

http://www.bkjia.com/PHPjc/478699.html www.bkjia.com true http://www.bkjia.com/PHPjc/478699.html techarticle in PHP, the getenv (parameter) function is a function to get environment variables, depending on the parameters available to obtain the different environment variables, as follows: Php_self is currently executing the foot ...

  • 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.