Thursday, June 18, 2009

PHP: Get the host name of a given domain

Share at Facebook

I didn't know that there is an easy function called gethostbyname() exist at PHP. I used to do ping from my php script, and obtained host IP address when I needed that before.

But I got the easiest way now. Its just a single line function call with the domain name to get the server IP address. Here is the example that will find the IP address of the domain hosted.

echo gethostbyname("");

This example code will print or something like that on screen for

No comments: