 [ ← blog / php ](/) Nov 24, 2011  ·  \#php  ·  1 min read 

# PHP Server Variables



 I know when I first started out learning PHP it was difficult finding good examples or live demos of simple PHP in use. Often I'd have a large number of files used to demonstrate built in PHP functions. So, to help any budding PHP developers out there [I compiled a list of the PHP Server variables](http://glamanate.com/playground/php_server.php "PHP $&#95;SERVER Variables") along with what data they provide. $_SERVER variables can be used in multiple ways from getting information about your visitors to script security.  For example, by using HTTP_HOST you can be sure that your web applications work regardless the domain.  For my own custom scripts I use the PHP_SELF variable with the dirname() function to get the base directory URL for requiring necessary files regardless the scripts domain or folder location. 

  ![](/themes/custom/mglaman/images/headshot.webp)Thanks for reading

I write about Drupal, PHP, and the quiet infrastructure behind large sites — caching, config, and testing. New posts land every week or two.

 [Subscribe via RSS →](/rss.xml) [About me →](/about-me) 

 



 

  [← Older

jQuery Contact Form

 ](/blog/jquery-contact-form) [Newer →

PHP Mail Class

 ](/blog/php-mail-class)