note 89725 modified in reserved.variables.environment by danbrown

From: Date: Fri, 20 Mar 2009 14:05:58 +0000
Subject: note 89725 modified in reserved.variables.environment by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152209@lists.php.net to get a copy of this message
When running a PHP program under the command line, the $_SERVER["SERVER_NAME"] variable does not contain the hostname. However, the following works for me under Unix/Linux and Windows: <?php if (isset($_ENV["HOSTNAME"])) $MachineName = $_ENV["HOSTNAME"]; else if (isset($_ENV["COMPUTERNAME"])) $MachineName = $_ENV["COMPUTERNAME"]; else $MachineName = ""; ?> --was-- When running a PHP program under the command line, the $_SERVER["SERVER_NAME"] variable does not contain the hostname. However, the following works for me under Unix/Linux and Windows: if (isset($_ENV["HOSTNAME"])) $MachineName = $_ENV["HOSTNAME"]; else if (isset($_ENV["COMPUTERNAME"])) $MachineName = $_ENV["COMPUTERNAME"]; else $MachineName = ""; http://php.net/manual/en/reserved.variables.environment.php

« previous php.notes (#152209) next »