How to check the Host IP address of a website or how to get Host IP of a Website. In this article i am going to tell you the function which we use for taking out the Host IP address or Host IP details. There are two methods which we will discuss here.
1. gethostbyname()
2. gethostbyaddr()
First we will get the Host IP address by entering the website name. Here we will use the gethostbyname() function.
<?php $a= gethostbyname("www.tata.com"); echo $a; ?>
It will show something like. – 64.37.102.54 – This is the Host IP.
Now we will show the Host address from IP. We will use gethostbyaddr() function.
<?php $b= gethostbyaddr("64.37.102.54"); echo $b; ?>
It will show you the Host name that is Tata.com.
Note – gethostbyaddr() – Most of the time it will show you the different Host name if you check the IP of the website. Because it will show the Host IP. So dont get confused by this.
No Comments