$_SERVER is one of the superglobal variables in PHP. It contains information about headers, server, host and etc. For that, it contains a huge list of information with appropriate global indices.
With these global indices, the $_SERVER array contains values for the meta-variables listed with the specification of the common gateway interface. So, while running a PHP script, the $_SERVER array will be loaded with the values based on the criteria, like, which interface the server is running and etc.
Now, we are going to see some of the lists of possible indices with the $_SERVER array in PHP. And also, we are going to see the factors based on which these array indices can be categorized.
So, $_server array indices contain information related to the list of the following items.
Let us look into the available indices of the $_SERVER array, that falls under each of the above lists, one by one.
Under this category, we are going to see the available indices of this PHP global array that are used to store information like accepted language and encoding technique, charset, connection and etc.
All of the above indices of the PHP $_SERVER array will be loaded with the values stored in the header while requesting a page from the server. And the captions to refer to these values with header content, are Host, Connection, Charset, Encoding, and Language, respectively.
Added to that, some other array indices in this category, which are used to hold details such as accepted MIME type, user agent and etc.
The $_server array contains indices that hold information about page requests as shown below.
The indices coming under this category will be used widely to create a full URL for the current page. For that, we can concatenate strings stored into the $_SERVER array with the following array indices.
This category includes a set of array indices that are used to store the name, address, and port of the remote user host, from which the page request is generated. And the corresponding indices are as follows.
And then, it also contains indices for storing authenticated users to access pages or to redirect. These array indices are,
HTTP authentication is used to let the user enter the username and password to access the requested page. Once, the user entered their username and password, it will be stored into the global variables, $_SERVER[“PHP_AUTH_USER”], $_SERVER[“PHP_AUTH_PW”], respectively.
HTTP authentication can be any one of basic or digest-type authentication. If we choose digest type, then, the $_SERVER[“PHP_AUTH_DIGEST”] will be set. And, $_SERVER[“PHP_AUTH_TYPE”] is used to store the type of authentication selected.