This is not always determined.
As indicated above, it is determined only if there is an HTTP request. If you use php script from the CLI (e.g. php filename.php), the HTTP_HOST key HTTP_HOST not be set.
In addition, you should notice that HTTP_HOST is defined by the client, so it is fairly easy to fake, and it is not reliable. You should rather rely on something like SERVER_NAME .
If you are using PHP> = 5.3.0 you should use
gethostname();
You can check here for documentation.
If you are using PHP> = 4.2.0 and PHP <5.3.0, then
php_uname('n');
will do the same job.
Savas vedova
source share