This tutorial will show you how you can use $_SERVER[] variables..



$_SERVER['DOCUMENT_ROOT']



Code:
<?php

echo $_SERVER['DOCUMENT_ROOT'];

?>


The document root directory under which the current script is executing, as defined in the server's configuration file.





$_SERVER['GATEWAY_INTERFACE']



Code:
<?php

echo $_SERVER['GATEWAY_INTERFACE'];

?>


What revision of the CGI specification the server is using; i.e. 'CGI/1.1'.



$_SERVER['HTTP_ACCEPT']



Code:
<?php

echo $_SERVER['HTTP_ACCEPT'];

?>


Contents of the Accept: header from the current request, if there is one.



$_SERVER['HTTP_ACCEPT_CHARSET']



Code:
<?php

echo $_SERVER['HTTP_ACCEPT_CHARSET'];

?>


Contents of the Accept-Charset: header from the current request, if there is one. Example: 'iso-8859-1,*,utf-8'.



$_SERVER['HTTP_ACCEPT_ENCODING']



Code:
<?php

echo $_SERVER['HTTP_ACCEPT_ENCODING'];

?>


Contents of the Accept-Encoding: header from the current request, if there is one. Example: 'gzip'.



$_SERVER['HTTP_ACCEPT_LANGUAGE']



Code:
<?php

echo $_SERVER['HTTP_ACCEPT_LANGUAGE'];

?>


Contents of the Accept-Language: header from the current request, if there is one. Example: 'en'.



$_SERVER['HTTP_CONNECTION']



Code:
<?php

echo $_SERVER['HTTP_CONNECTION'];

?>


Contents of the Connection: header from the current request, if there is one. Example: 'Keep-Alive'.



$_SERVER['HTTP_HOST']



Code:
<?php

echo $_SERVER['HTTP_HOST'];

?>


Contents of the Host: header from the current request, if there is one.



$_SERVER['HTTP_REFERER']



Code:
<?php

echo $_SERVER['HTTP_REFERER'];

?>


The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.



$_SERVER['HTTP_USER_AGENT']



Code:
<?php

echo $_SERVER['HTTP_USER_AGENT'];

?>


Contents of the User-Agent: header from the current request, if there is one. This is a string denoting the user agent being which is accessing the page. A typical example is: Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586). Among other things, you can use this value with get_browser() to tailor your page's output to the capabilities of the user agent.



$_SERVER['PATH_TRANSLATED']



Code:
<?php

echo $_SERVER['PATH_TRANSLATED'];

?>


Filesystem- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping.



Note: As of PHP 4.3.2, PATH_TRANSLATED is no longer set implicitly under the Apache 2 SAPI in contrast to the situation in Apache 1, where it's set to the same value as the SCRIPT_FILENAME server variable when it's not populated by Apache. This change was made to comply with the CGI specification that PATH_TRANSLATED should only exist if PATH_INFO is defined.



Apache 2 users may use AcceptPathInfo = On inside httpd.conf to define PATH_INFO.



$_SERVER['PHP_SELF']



Code:
<?php

echo $_SERVER['PHP_SELF'];

?>


The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.



If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available.



$_SERVER['QUERY_STRING']



Code:
<?php

echo $_SERVER['QUERY_STRING'];

?>


The query string, if any, via which the page was accessed.



$_SERVER['REMOTE_ADDR']



Code:
<?php

echo $_SERVER['REMOTE_ADDR'];

?>


The IP address from which the user is viewing the current page.



$_SERVER['REMOTE_PORT']



Code:
<?php

echo $_SERVER['REMOTE_PORT'];

?>


The port being used on the user's machine to communicate with the web server.



$_SERVER['REQUEST_METHOD']



Code:
<?php

echo $_SERVER['REQUEST_METHOD'];

?>


Which request method was used to access the page; i.e. 'GET', 'HEAD', 'POST', 'PUT'.

Note: PHP script is terminated after sending headers (it means after producing any output without output buffering) if the request method was HEAD.



$_SERVER['REQUEST_URI']



Code:
<?php

echo $_SERVER['REQUEST_URI'];

?>


The URI which was given in order to access this page; for instance, '/index.html'.



$_SERVER['SCRIPT_FILENAME']



Code:
<?php

echo $_SERVER['SCRIPT_FILENAME'];

?>


The absolute pathname of the currently executing script.

Note: If a script is executed with the CLI, as a relative path, such as file.php or ../file.php, $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user.



$_SERVER['SCRIPT_NAME']



Code:
<?php

echo $_SERVER['SCRIPT_NAME'];

?>


Contains the current script's path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.



$_SERVER['SERVER_ADMIN']



Code:
<?php

echo $_SERVER['SERVER_ADMIN'];

?>


The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file. If the script is running on a virtual host, this will be the value defined for that virtual host.



$_SERVER['SERVER_NAME']



Code:
<?php

echo $_SERVER['SERVER_NAME'];

?>


The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.



$_SERVER['SERVER_PORT']



Code:
<?php

echo $_SERVER['SERVER_PORT'];

?>


The port on the server machine being used by the web server for communication. For default setups, this will be '80'; using SSL, for instance, will change this to whatever your defined secure HTTP port is.



$_SERVER['SERVER_PROTOCOL']

Code:
<?php

echo $_SERVER['SERVER_PROTOCOL'];

?>


Name and revision of the information protocol via which the page was requested; i.e. 'HTTP/1.0';



$_SERVER['SERVER_SIGNATURE']



Code:
<?php

echo $_SERVER['SERVER_SIGNATURE'];

?>


String containing the server version and virtual host name which are added to server-generated pages, if enabled.



$_SERVER['SERVER_SOFTWARE']

Code:
<?php

echo $_SERVER['SERVER_SOFTWARE'];

?>


Server identification string, given in the headers when responding to requests.



Info taken from php.net

some of those echo example might not work because some of those variables don't have output!