$_SERVER array contains
a lot of useful information from the web server. Much of this information
comes from the environment variables required in the CGI specification.
Here is a complete list of the entries in
$_SERVER that come from CGI:
The name of the current script, relative to the document root (e.g., /store/cart.php). You should already have noted seeing this used in some of the sample code in earlier chapters. This variable is useful when creating self-referencing scripts, as we’ll see later.
A string that identifies the server (e.g., “Apache/1.3.33 (Unix) mod_perl/1.26 PHP/5.0.4”).
The hostname, DNS alias, or IP address for self-referencing URLs (e.g., www.example.com).
The version of the CGI standard being followed (e.g., “CGI/1.1”).
The name and revision of the request protocol (e.g., “HTTP/1.1”).
The server port number to which the request was sent (e.g., “80”).
The method the client used to fetch the document (e.g., “GET”).
Extra path elements given by the client (e.g., /list/users).
The value of
translated by the server into a filename (e.g., /home/httpd/htdocs/list/users).
The URL path to the current page, which is useful for self-referencing scripts (e.g., /~me/menu.php).
Everything after the
the URL (e.g., name=Fred+age=35).
The hostname of the machine that requested this page (e.g., “dialup-192-168-0-1.example.com ...