Page 1 of 1

get server ip?

Posted: Fri Dec 22, 2006 5:05 pm
by Deathblade
i was wondering if there was a way to use PHP to get the ip address of a server...

like the DOS command ping, i could type 'ping http://www.google.com' and it would output the ip address of the server. is there a way to do this in PHP? thanks a lot,

DeathBlade

Posted: Fri Dec 22, 2006 5:16 pm
by timvw
Actually ping is not the right tool to do that... Since a hostname can resolve to multiple ip addreses... Anyway, for php you might want to look at http://www.php.net/gethostbynamel (read the user comments too).

Posted: Fri Dec 22, 2006 5:42 pm
by Deathblade
exactly what i was looking for, thanks a lot mate