Thursday, June 18, 2009

PHP: Get the host name of a given domain

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("zit7.com");

This example code will print 82.98.86.165 or something like that on screen for zit7.com

1 comment:

Blogger said...

DreamHost is the best web-hosting company with plans for all of your hosting needs.

Get function name programaticaly - Python

This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...