How to get a server's hostname in PHP

1 · Josh Sherman · March 15, 2015, midnight
The hostname of your server or local system is an easy way to determine which environment you are working with, either local or production. Prior to PHP 5.3 you would need to utilize the php_uname() function and with 5.3+ there is a built-in function for getting the hostname: pre-5.3 $hostname......