Lecture
Immediately before running the script, the server sends it some environment variables with information. Certain variables contain some headers, but, as already mentioned, not all (you cannot get all the headers). Environment variables in the PHP language can be used as the most ordinary variables. Environment variables are divided into four large groups:
Consider the first three groups of environment variables:
Variables generated by the server:
Environment variable | Description of the environment variable |
AUTH_TYPE | The authentication scheme is used. Usually 'BASIC' |
CONTENT_LENGTH | Content length, for example, text / html |
CONTENT_TYPE | MIME content type, for example, text / html |
GETAWAY_INTERFACE | CGI version, for example CGI / 1.1 |
PATH_INFO | HTTP script path |
PATH_TRANSLATED | Full path to the script |
REMOTE_ADDR | IP address of the requested client computer |
REMOTE_HOST | The domain name of the requesting computer (if available). The domain name is determined by the web server using DNS. Apache's HostNameLookups directive allows (or denies) the conversion of an IP address to a domain name. |
REMOTE_PORT | Port assigned to the browser to receive a response from the server |
REMOTE_USER | Authenticated username |
QUERY_STRING | The string of parameters passed to the server |
SERVER_ADDR | Server ip address |
SERVER_NAME | The domain name of the server. Determined by the ServerName directive of the configuration file |
SERVER_PORT | TCP port of the web server. Usually 80 |
SERVER_PROTOCOL | HTTP protocol version. For example, HTTP / 1.1 |
SERVER_SOFTWARE | Server software |
SCRIPT_NAME | HTTP script path |
SCRIPT_FILENAME | The file name of the script in the server file system (physical path). For example, /var/www/cgi-bin/script.cgi |
Apache server special variables:
Environment variable | Description of the environment variable |
DOCUMENT_ROOT | The physical path to the root www-directory of the server. For example, /var/www.html/ |
SERVER_ADMIN | Server Admin Email |
SERVER_SIGNATURE | Server signature For example, "Apache / 1.3.3 Server at www.somefirm.com Port 80" |
HTTP request field variables:
Environment variable | Description of the environment variable |
HTTP_HOST | The name of the virtual host to which the request is addressed. |
HTTP_USER_AGENT | Remote user software. Usually this environment variable contains the name and version of the browser. |
HTTP_ACCEPT | List of supported client content types. Recently, instead of a list, browsers return the value *. *, Which means "all types" |
HTTP_ACCEPT_LANGUAGE | List of supported languages in order of preference, for example, ru, en |
HTTP_ACCEPT_ENCODING | List of supported compression methods |
HTTP_ACCEPT_CHARSET | List of supported encodings |
HTTP_CONNECTION | Connection type. Two options are possible:
|
HTTP_REFERER | The value of the REFERER field. In this field, the browser sends the URL of the resource that refers to our server. For example, if a user navigates to the site from http://www.somehost.com/page.php, then the value of the REFERER field will be http://www.somehost.com/page.php. |
HTTP_X_FORWARDED_FOR | If the user is working through a proxy server, then this field will contain the IP address of the computer accessing the proxy server. If this field already contains a value, then the new value will be added separated by commas. |
Comments
To leave a comment
Running server side scripts using PHP as an example (LAMP)
Terms: Running server side scripts using PHP as an example (LAMP)