$_SERVER

(PHP 4 >= 4.1.0, PHP 5, PHP 7)
Server and execution environment information

$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here. That said, a large number of these variables are accounted for in the » CGI/1.1 specification, so you should be able to expect those.

Note: Prior to PHP 5.4.0, $HTTP_SERVER_VARS contained the same initial information, but was not a superglobal. (Note that $HTTP_SERVER_VARS and $_SERVER were different variables and that PHP handled them as such.)

Changelog:
5.4.0

$HTTP_SERVER_VARS

5.3.0

Directive register_long_arrays which caused $HTTP_SERVER_VARS to be available has been deprecated.

4.1.0

Introduced $_SERVER that deprecated $HTTP_SERVER_VARS.

Notes:

This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. There is no need to do global $variable; to access it within functions or methods.

Examples:
$_SERVER example
<?php
echo $_SERVER['SERVER_NAME'];
?>

The above example will output something similar to:

www.example.com
See also:

The filter extension -

doc_php
2016-02-24 15:53:12
Comments
Leave a Comment

Please login to continue.