Andreas <> wrote:

> Am 26.11.2011 01:35, schrieb Simon J Welsh:
> > On 26/11/2011, at 1:14 PM, Andreas wrote:
> >
> >> how could I identify the server the script runs on?
> >>
> >
> > php_uname('n');
> >
> Great, that even works on a ssh-tunnel.
> I got derailed by the fact that my tunnel maps the remote server to
> localhost:80 so
> $_SERVER['SERVER_NAME']   wouldn't help.
> On the other hand for everyone on the remote LAN $_SERVER['...'] would
> work ok, though I didn't realise that before.

This may work in some circumstances, but not others. 

For example, I have a VPS with several sites hosted on it. php_uname
will always return the default host name, which very likely might be
different than the virtual host's hostname.

I'm not doing any ssh tunnelling in my local setups, so looking at
$_SERVER['SERVER_NAME'] works for me, but obviously won't for you. I
simply set up the /etc/hosts file with a lot of aliases, and then they
can become virtual hosts.

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to