Immediately before starting the script, the server passes it some environment variables with information. Certain variables contain some headers, but not all (you can't get all the headers).
HTTP_ACCEPT- This variable lists all MIME data types that can be accepted by the browser. The line */* means that the browser understands any type.
HTTP_ACCEPT= */*
HTTP_REFERER- This variable represents information about the page from which the user came to this one. You can use this variable, for example, to track a user's movement around your site and then view the most popular routes.
HTTP_REFERER= http://www.spravkaweb.ru/
HTTP_COOKIE- This variable stores all URL-encoded Cookies.
HTTP_COOKIE=
HTTP_USER_AGENT- Identifies the user's browser. To establish the browser type, you need to check this line for the presence of words: if the browser is Internet Explorer, then the MSIE substring will be present, and if only the word Mozilla is present, then this is Netscape.
HTTP_USER_AGENT= Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 4.0)
You have Internet Explorer
HTTP_HOST- Contains the domain name of the Web server on which the script ran. This variable is quite convenient to use, for example, to generate the full path, which is required in the Location header so as not to be tied to a specific server.
HTTP_HOST= www.spravkaweb.ru
HTTP_FROM- Email address of the user who sent the request.
HTTP_FROM=
SERVER_NAME- Domain name or server IP address.
SERVER_NAME= www.spravkaweb.ru
SERVER_SOFTWARE- The name and version of the server program responding to the client request.
SERVER_SOFTWARE= Apache/1.3.33 (Unix) mod_jk/1.2.8 mod_auth_passthrough/1.8 mod_log_bytes/1.2mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_ssl/2.8.22 OpenSSL/0.9.7a PHP-CGI/0.1b
SERVER_PORT- This variable contains the server port that the user's browser accessed. Typically this is 80. The variable can also be used to form the Location header parameter.
SERVER_PORT= 80
SERVER_PROTOCOL- The variable contains the name and version of the information protocol that was used for the request.
SERVER_PROTOCOL= HTTP/1.0
REMOTE_ADDR- This variable contains the IP address (or domain name) of the user's host on which the browser was launched.
REMOTE_ADDR= 212.94.114.177
REMOTE_PORT- The port that is assigned to the user's browser to receive the server response.
REMOTE_PORT= 4277
REMOTE_USER- The identification name of the user sending the request.
REMOTE_USER=
SCRIPT_NAME- Contains the name of the file containing this script. This variable is convenient to use when forming the Location header when redirecting to yourself (self-redirect), as well as for substituting the value of the action attribute of the tag
DOCUMENT_ROOT
The root directory of the Web document tree.
REQUEST_METHOD
The method the user uses when transferring data. It should be noted that a well-written script should itself determine, based on this variable, which method the user is using, and receive data from the appropriate source, and not expect that the transfer will be carried out, for example, only by the POST method.
QUERY_STRING
Contains the parameters that appear after the question mark in the URL. Let us remind you that they are available both with the GET and POST methods (if in the latter case they were defined in the action attribute of the tag
PATH_INFO
Contains additional information about the path.
PATH_TRANSLATED
Same information as in the variable PATH_INFO with a prefix specifying the path to the root directory of the Web document tree.
CONTENT_TYPE
Media data type of the request.
CONTENT_LENGTH
Returns the number of bytes of data sent by the user. This variable needs to be analyzed if you are accepting and processing a POST form.
GATEWAY_INTERFACE
The CGI version the server is using.
Example of using environment variables
Environment Variables:
echo "You came from: ".getenv("HTTP_REFERER")."
";
$br=getenv("HTTP_USER_AGENT");
if(strpos($br,"MSIE")!==false) echo "You have Internet Explorer
";
else echo "You have Netscape or others.
";
echo "Your IP: ".getenv("REMOTE_ADDR")."
";
echo "Here are the parameters in the browser line: ".getenv("QUERY_STRING");
From the book The Art of Programming for Unix author Raymond Eric Stephen From the book The Art of Programming for Unix author Raymond Eric Stephen From the book Programming in Ruby [Language ideology, theory and practice of application] by Fulton Hal From the book HTML 5, CSS 3 and Web 2.0. Development of modern Web sites. author Dronov Vladimir From the book Application Development in the Linux Environment. Second edition author Johnson Michael K.10.4. Environment Variables When a Unix program runs, the environment available to it includes a set of name-value relationships (both names and values are strings). Some of them are installed manually by the user, others are installed by the system during
From the book Firebird DATABASE DEVELOPER'S GUIDE by Borri Helen10.4.1. System Environment Variables There are many well-known environment variables that a program can obtain when run from a Unix shell. These variables (especially HOME) often need to be evaluated before reading the local file
From the book Linux Programming with Examples author Robbins Arnold10.4.2. Custom Environment Variables Although applications are free to interpret environment variables outside of the system-defined set, actual use of such a feature is currently quite unusual.
From the author's book10.4.3. When to Use Environment Variables What both user and system environment variables have in common is that they contain data that would be tedious to store in a large number of configuration files. And extremely tiring
From the author's book14.4. Environment Variables Sometimes it is necessary to access environment variables, which are the link between the program and the outside world. Environment variables are simply labels associated with some text (usually small); they store, for example, paths to
From the author's bookFunctions and variables. Local Variables Previously declared functions create their own variables within their body. These are so-called local variables. Such variables are only accessible within the function body in which they are declared. When execution completes
From the author's book22.3.3. Environment Variables In programs that use setuid or setgid capabilities, special care must be taken with environment settings. These variables are determined by the user who activated the program, thereby opening the door for attacks. The most obvious attack
From the author's bookEnvironment variables Environment variables are global system settings that are used when the operating system initially boots. On Windows, Linux, and most UNIX systems, the Firebird server recognizes and uses certain environment variables if they
From the author's bookWhere Windows Environment Variables Are SetThe type of environment variables and how they are set varies from one version of Windows to another. In table Table 3.1 shows the types (if applicable) and methods of setting the values of environment variables. Table 3.1. Environment variable settings for
From the author's bookChapter 2 Arguments, Options, and Environment Variables The first task of any program is usually to interpret command-line options and arguments. This chapter examines how C (and C++) programs receive their command line arguments, describing standard
Immediately before starting the script, the server passes it some environment variables with information. Certain variables contain some headers, but not all (you can't get all the headers). Below I will provide a list of the most important environment variables.
HTTP_ACCEPT
This variable lists all MIME data types, which can be interpreted by the browser. The line */* means that the browser understands any type.
HTTP_ACCEPT= image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/msword, */*
HTTP_REFERER
This variable represents information about the page from which the user arrived at this one. You can use this variable, for example, to track a user's movement around your site and then view the most popular routes.
HTTP_REFERER= http://www.site/php/pril/
HTTP_COOKIE
This variable stores all URL-encoded Cookies.
HTTP_COOKIE= hotlog=1; ZDEDebuggerPresent=php,phtml,php3; b=b; PHPSESSID=
HTTP_USER_AGENT
Identifies the user's browser. To establish the browser type, you need to check this line for the presence of words: if the browser is Internet Explorer, then the MSIE substring will be present, and if only the word Mozilla is present, then this is Netscape.
For example:
HTTP_USER_AGENT= Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; MyIE2; Maxthon)
HTTP_HOST
Contains the domain name of the Web server on which the script ran. This variable is quite convenient to use, for example, to generate the full path, which is required in the Location header so as not to be tied to a specific server.
HTTP_HOST= www.site
HTTP_FROM
Email address of the user who sent the request.
SERVER_NAME
Domain name or server IP address.
SERVER_NAME= www.site
SERVER_SOFTWARE
The name and version of the server program responding to the client request.
SERVER_PORT
This variable contains the server port that the user's browser accessed. Typically this is 80. The variable can also be used to form the Location header parameter.
SERVER_PORT= 80
SERVER_PROTOCOL
The variable contains the name and version of the information protocol that was used for the request.
SERVER_PROTOCOL= HTTP/1.1
REMOTE_ADDR
This variable contains the IP address (or domain name) of the user's host on which the browser was launched.
REMOTE_PORT
The port that is assigned to the user's browser to receive the server response.
REMOTE_USER
The identification name of the user making the request.
SCRIPT_NAME
Contains the name of the file containing this script. This variable is convenient to use when forming the Location header when redirecting to yourself (self-redirect), as well as for substituting the value of the action attribute of the tag
DOCUMENT_ROOT
The root directory of the Web document tree.
REQUEST_METHOD
The method the user uses when transferring data. It should be noted that a well-written script should itself determine, based on this variable, which method the user is using, and receive data from the appropriate source, and not expect that the transfer will be carried out, for example, only by the POST method.
QUERY_STRING
Contains the parameters that appear after the question mark in the URL. Let us remind you that they are available both with the GET and POST methods (if in the latter case they were defined in the action attribute of the tag
PATH_INFO
Contains additional information about the path.
PATH_TRANSLATED
Same information as in the variable PATH_INFO with a prefix specifying the path to the root directory of the Web document tree.
CONTENT_TYPE
Media data type of the request.
CONTENT_LENGTH
Returns the number of bytes of data sent by the user. This variable needs to be analyzed if you are accepting and processing a POST form.
GATEWAY_INTERFACE
The CGI version the server is using.
Example of using environment variables
Environment Variables:
echo "Вы пришли из: ".getenv("HTTP_REFERER")."
"; $br=getenv("HTTP_USER_AGENT"); if(strpos($br,"MSIE")!==false) echo "You have Internet Explorer
"; else echo "You have Netscape or others.
"; echo "Your IP: ".getenv("REMOTE_ADDR")."
"; echo "Here are the parameters in the browser line: ".getenv("QUERY_STRING"); ?>
Environment Variables
Environment Variables in PHP
Immediately before starting the script, the server passes it some environment variables with information. Certain variables contain some headers, but not all (you can't get all the headers). Below I will provide a list of the most important environment variables.
HTTP_ACCEPT
This variable lists all MIME data types, which can be interpreted by the browser. The line */* means that the browser understands any type.
HTTP_ACCEPT= image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/msword, */*
HTTP_REFERER
This variable represents information about the page from which the user arrived at this one. You can use this variable, for example, to track a user's movement around your site and then view the most popular routes.
HTTP_REFERER= http://www.spravkaweb.ru/php/pril/
HTTP_COOKIE
This variable stores all URL-encoded Cookies.
HTTP_COOKIE= hotlog=1; ZDEDebuggerPresent=php,phtml,php3; b=b; PHPSESSID=16805922a9258cda274316e60f649cf8
HTTP_USER_AGENT
Identifies the user's browser. To establish the browser type, you need to check this line for the presence of words: if the browser is Internet Explorer, then the MSIE substring will be present, and if only the word Mozilla is present, then this is Netscape.
For example:
HTTP_USER_AGENT= Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; MyIE2; Maxthon)
HTTP_HOST
Contains the domain name of the Web server on which the script ran. This variable is quite convenient to use, for example, to generate the full path, which is required in the Location header so as not to be tied to a specific server.
HTTP_HOST= www.spravkaweb.ru
HTTP_FROM
Email address of the user who sent the request.
SERVER_NAME
Domain name or server IP address.
SERVER_NAME= www.spravkaweb.ru
SERVER_SOFTWARE
The name and version of the server program responding to the client request.
SERVER_PORT
This variable contains the server port that the user's browser accessed. Typically this is 80. The variable can also be used to form the Location header parameter.
SERVER_PROTOCOL
The variable contains the name and version of the information protocol that was used for the request.
SERVER_PROTOCOL= HTTP/1.1
REMOTE_ADDR
This variable contains the IP address (or domain name) of the user's host on which the browser was launched.
REMOTE_PORT
The port that is assigned to the user's browser to receive the server response.
REMOTE_USER
The identification name of the user making the request.
SCRIPT_NAME
Contains the name of the file containing this script. This variable is convenient to use when forming the Location header when redirecting to yourself (self-redirect), as well as for substituting the value of the action attribute of the tag
DOCUMENT_ROOT
The root directory of the Web document tree.
REQUEST_METHOD
The method the user uses when transferring data. It should be noted that a well-written script should itself determine, based on this variable, which method the user is using, and receive data from the appropriate source, and not expect that the transfer will be carried out, for example, only by the POST method.
QUERY_STRING
Contains the parameters that appear after the question mark in the URL. Let us remind you that they are available both with the GET and POST methods (if in the latter case they were defined in the action attribute of the tag
PATH_INFO
Contains additional information about the path.
PATH_TRANSLATED
Same information as in the variable PATH_INFO with a prefix specifying the path to the root directory of the Web document tree.
CONTENT_TYPE
Media data type of the request.
CONTENT_LENGTH
Returns the number of bytes of data sent by the user. This variable needs to be analyzed if you are accepting and processing a POST form.
GATEWAY_INTERFACE
The CGI version the server is using.
Example of using environment variables