PHP Server Variables

Published on Thursday 24, November 2011
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 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.