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.

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.

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.