Re: Howto detect the hostname of the server?
| From: | Mark Kelly | Date: | Sat, 26 Nov 2011 00:28:23 +0000 |
| Subject: | Re: Howto detect the hostname of the server? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-315811@lists.php.net to get a copy of this message | ||
Hi.
On Saturday 26 Nov 2011 at 00:14 Andreas wrote:
> how could I identify the server the script runs on?
[snip]
> I looked into phpinfo() but haven't found anything helpful, yet.
> Have I overlooked something or is there another way to identify the server?
Wouldn't the server IP address in $_SERVER['SERVER_ADDR'] or the hostname in
$_SERVER['SERVER_NAME'] do the trick? That's what I use. The second one is
handy for differentiating between sites when using Apache name-based virtual
hosts on the same IP.
Full list here:
http://uk.php.net/manual/en/reserved.variables.server.php
Cheers,
Mark