Skip to Content
Programming PHP
book

Programming PHP

by Rasmus Lerdorf, Kevin Tatroe
March 2002
Intermediate to advanced
528 pages
21h 29m
English
O'Reilly Media, Inc.
Content preview from Programming PHP

Server Information

The $_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 (http://hoohoo.ncsa.uiuc.edu/cgi/env.html).

Here is a complete list of the entries in $_SERVER that come from CGI:

SERVER_SOFTWARE

A string that identifies the server (e.g., “Apache/1.3.22 (Unix) mod_perl/1.26 PHP/4.1.0”).

SERVER_NAME

The hostname, DNS alias, or IP address for self-referencing URLs (e.g., “www.example.com”).

GATEWAY_INTERFACE

The version of the CGI standard being followed (e.g., “CGI/1.1”).

SERVER_PROTOCOL

The name and revision of the request protocol (e.g., “HTTP/1.1”).

SERVER_PORT

The server port number to which the request was sent (e.g., “80”).

REQUEST_METHOD

The method the client used to fetch the document (e.g., “GET”).

PATH_INFO

Extra path elements given by the client (e.g., “/list/users”).

PATH_TRANSLATED

The value of PATH_INFO, translated by the server into a filename (e.g., “/home/httpd/htdocs/list/users”).

SCRIPT_NAME

The URL path to the current page, which is useful for self-referencing scripts (e.g., “/~me/menu.php”).

QUERY_STRING

Everything after the ? in the URL (e.g., “name=Fred+age=35”).

REMOTE_HOST

The hostname of the machine that requested this page (e.g., “dialup-192-168-0-1.example.com”). If there’s no DNS for the machine, this is blank and REMOTE_ADDR is the only information given.

REMOTE_ADDR

A string containing the IP address of the machine ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming PHP, 3rd Edition

Programming PHP, 3rd Edition

Rasmus Lerdorf, Kevin Tatroe, Peter MacIntyre
Programming PHP, 2nd Edition

Programming PHP, 2nd Edition

Rasmus Lerdorf, Kevin Tatroe, Peter MacIntyre
Clean Code in PHP

Clean Code in PHP

Carsten Windler, Alexandre Daubois

Publisher Resources

ISBN: 1565926102Supplemental ContentCatalog PageErrata