HOSTNAME not a CGI environment variable, therefore it is not present in regular PHP scripts.
But you can also use
$hostname = `hostname`; // exec backticks
Or read the system configuration file:
$hostname = file_get_contents("/etc/hostname");
But most PHP scripts should just use $_SERVER["SERVER_NAME"] or requested by the client $_SERVER["HTTP_HOST"]
mario source share