get server ip?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Deathblade
Forum Newbie
Posts: 11
Joined: Mon Oct 30, 2006 5:57 pm

get server ip?

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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).
Deathblade
Forum Newbie
Posts: 11
Joined: Mon Oct 30, 2006 5:57 pm

Post by Deathblade »

exactly what i was looking for, thanks a lot mate
Post Reply