What are the useful fields of $_SERVER array in PHP
The following table describes useful fields in $_SERVER array in PHP.
| Name | Description |
|---|---|
| PHP_SELF | Returns the filename of the current script |
| SERVER_PROTOCOL | Name and revision of the information protocol ‘HTTP/1.0‘ or ‘HTTP/1.1′ |
| REQUEST_METHOD | Returns the request method used to access (GET/POST/PUT) |
| REQUEST_TIME | Returns the timestamp from the beginning |
| DOCUMENT_ROOT | Returns the root directory under which the current script is executing. This directory is based on server’s configuration. |
| HTTP_REFERER | Returns the page address that referred |
| HTTP_USER_AGENT | Returns the contents of user agent extracted from HTTP header. This information is typically used for identification of user’s browser and operating system. |
| REMOTE_ADDR | Returns the IP address of the current user |
| REMOTE_PORT | Returns the port of the user’s machine |
| SCRIPT_FILENAME | Returns the absolute path of current script |
| SCRIPT_NAME | Returns the path of the current script |
If you want to look at all fields in $_SERVER variable, place the following PHP script in the web server and access it using a browser.
<html> <head> <title>$_SERVER variable information </head> <body> <h1>Dump of $_SERVER variable</h1> <pre> <?php print_r($_SERVER); ?> </pre> </body> </html>

