954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

get ip address of user entered website

Hi all,

I need a php script that gets the IP address of a user entered website, something like this:

$site = 'www.google.com';

$ip = ping($site);

obviously replacing ping with a command that actually exists!

Thanks in advance.
MAX

MaxMumford
Posting Whiz in Training
228 posts since Oct 2006
Reputation Points: 32
Solved Threads: 3
 

PHP comes with a fully functioning sockets API which you can find a tutorial for on Google. A function you could use is the 'gethostbyname()' function which accepts a hostname as a parameter and then returns that hosts IPv4 address.

See here for more information.

I hope this helps.
$witch3d.

switch3d
Newbie Poster
6 posts since Dec 2009
Reputation Points: 7
Solved Threads: 1
 

ahhh briliant, that should work perfectly. I dont have time to test it now but when I do ill mark the thread as solved.

Thanks again!
Max.

MaxMumford
Posting Whiz in Training
228 posts since Oct 2006
Reputation Points: 32
Solved Threads: 3
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: