Php Server Variable


$_SERVER is an array containing data, for example, headers, paths, and script locations. the passages in this exhibit are made by the webserver. There is no assurance that each web server will give any of these serves may preclude a few, or give others not recorded here.

This is a 'superglobal' or automatic global, variable. this just implies it is accessible in all extensions all through a content.. you don't need to do a global $_SERVER to access it within functions or methods, as you do with $HTTP_SERVER_VARS. $HTTP_SERVER_VARS and $_SERVER are different variables and that PHP handles them as such.

SERVER_NAME

The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.

SERVER_SOFTWARE

Server identification string, given in the headers when responding to requests.

SERVER_PROTOCOL

Name and revision of the information protocol via which the page was requested. i.e. 'HTTP/1.0';

REQUEST_METHOD

Which request method was used to access the page; i.e. 'GET','POST'.

QUERY_STRING

The query string, if any via which the page was accessed.

DOCUMENT_ROOT

The document root directory under which the current script is executing, as defined in the sever's configuration file.

HTTP_HOST

Contents of the Host: header from the current request, if there if one.

SCRIPT_FILENAME

The absolute pathname of the currently executing script.

SERVER_PORT

The port on the server machine being used by the webserver for communication. for default setups, this will be '80'; using SSL for instance, will change this to whatever you defined secure HTTP port is.

SCRIPT_NAME

It contains the current script's path. This is useful for pages that need to point to themselves.

REQUEST_URI

The URI which was given in order to access this page; for instance,'/index.html'.