PHP » Predefined Variables » Server variables

Syntax:
$_SERVER

The $_SERVER autoglobal contains information about the web server. What this includes exactly, depends on the web server. However, it usually provides information such as server version and configuration, HTTP headers, and CGI environment variables.

Examples

Code:
<?php

$value = current($_SERVER);
do {
   print key($_SERVER) . ": $value<br>";
} while ($value = next($_SERVER))

?>
Output:
UNIQUE_ID: irJL2X8AAAEAAAlNLdMAAAAC
HTTP_ACCEPT: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
HTTP_REFERER: http://192.168.246.128/samples/
HTTP_ACCEPT_LANGUAGE: sv
HTTP_ACCEPT_ENCODING: gzip, deflate
HTTP_USER_AGENT: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)
HTTP_HOST: 192.168.246.128
HTTP_CONNECTION: Keep-Alive
PATH: /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
SERVER_SIGNATURE:
Apache/2.0.40 Server at 192.168.246.128 Port 80

SERVER_SOFTWARE: Apache/2.0.40 (Red Hat Linux)
SERVER_NAME: 192.168.246.128
SERVER_ADDR: 192.168.246.128
SERVER_PORT: 80
REMOTE_ADDR: 192.168.246.1
DOCUMENT_ROOT: /var/www/html
SERVER_ADMIN: root@localhost
SCRIPT_FILENAME: /var/www/html/samples/vars_server.php
REMOTE_PORT: 3932
GATEWAY_INTERFACE: CGI/1.1
SERVER_PROTOCOL: HTTP/1.1
REQUEST_METHOD: GET
Explanation:

This is an example of what kind of variables can be available in the $_SERVER array.

See Also: