Valid XHTML Icon Valid CSS Icon Valid SVG Icon Unicode UTF-8 Icon
Add to del.icio.us Digg this! Post to reddit Share on Facebook Add to StumbleUpon Add to Google Bookmarks

PHP $_SERVER Variable

Creative Commons LogoThis work is licensed under the Creative Commons Attribution Non-Commercial 2.0 UK: England & Wales Licence. This means that you are free to: copy; distribute; and modify this work. It also means that you cannot use it for commercial purposes. Additionally, you must attribute this work to the original author, Thomas Guymer, ideally with a link.

This is just a simple page to show the live output from the PHP variable $_SERVER. This variable is pre-defined in PHP which means that it can be called anywhere and does not have to be initialised. Plus, to state the obvious, as it is PHP it does not rely on JavaScript and so it is quick and cannot be switched off by the user.

Array {
    [HTTP_X_CC_ID] => ccc02-02
    [HTTP_HOST] => www.thomasguymer.co.uk
    [HTTP_USER_AGENT] => CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,text/xml;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    [HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5
    [HTTP_ACCEPT_ENCODING] => gzip
    [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7
    [HTTP_CONNECTION] => close
    [HTTP_CACHE_CONTROL] => no-cache
    [HTTP_PRAGMA] => no-cache
    [HTTP_COOKIE] => ImageSize=small; ThumbSize=thumb
    [PATH] => withheld for security reasons
    [SERVER_SIGNATURE] =>
    [SERVER_SOFTWARE] => Apache/2.2.3 (CentOS)
    [SERVER_NAME] => www.thomasguymer.co.uk
    [SERVER_ADDR] => 10.9.16.16
    [SERVER_PORT] => 80
    [REMOTE_ADDR] => 38.107.191.99
    [DOCUMENT_ROOT] => withheld for security reasons
    [SERVER_ADMIN] => withheld for security reasons
    [SCRIPT_FILENAME] => withheld for security reasons
    [REMOTE_PORT] => withheld for security reasons
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [REQUEST_METHOD] => GET
    [QUERY_STRING] =>
    [REQUEST_URI] => /tutorials/php-server-variable/
    [SCRIPT_NAME] => withheld for security reasons
    [PHP_SELF] => withheld for security reasons
    [REQUEST_TIME] => 1284053888
}

Using these details you can create one mean web statistics package or just some helpful user related content.

This page was last modified on 02/03/2010. This page has had 442 hits up until 13/06/2010.

Amazon.co.uk logoDo you want to say thank you? Visit my Amazon Wishlist, thank you.Amazon dummy image

Random Photo:

(from My Portfolio)

© 2002-2010 Thomas Guymer. See the Copyright Statement & the Cookie Policy.