Re: getting ip of server
| From: | Torgny Bjers | Date: | Fri, 12 Aug 2005 14:09:51 +0000 |
| Subject: | Re: getting ip of server | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-220517@lists.php.net to get a copy of this message | ||
Tom Cruickshank wrote:
> Hello,
> I'm curious to know if there is a php command that can get the IP of the
> server it's running on. I could always do this...
>
> $results = exec("/sbin/ifconfig <ethernet device> | grep broadcast | awk
> '{print $2}'", $value);
>
> but I would prefer to not have to use system commands for this.
>
> Would anyone happen to know?
This is one of the few times I say RTFM :D
http://www.php.net/manual/en/language.variables.predefined.php
Look under $_SERVER and there's a whole bunch of nice stuff.
Regards,
Torgny