WebRef.eu  - Internet Marketing and Online Business Resources  

Home / Site Map | Blog | TwitterTwitter | Contact

Obtain Site Domain Name in PHP

Sometimes you want to automatically obtain the site domain name in PHP. This technique means you don't have to hard code references to the site domain name in your script, making it easier for your script to be used on other sites.

E.g. if the url of your script was:


and you wanted to put the site domain into a variable, i.e. put www.mysite.co.uk into a variable, the code to use would be:

$domain = $_SERVER['HTTP_HOST'];


Low Prices UK Shopping

Compare Prices
at LowPrices.co.uk

Home / Site Map | TwitterTwitter | Contact

All Content ©2018 WebRef.eu