Php - How to get ip address of a domain, Fetch IP-Address of a website

How to get ip address of a domain

To get an IP of a website in php, generally we use,
  gethostbyname("example.com");
This will work nicely, but for some urls instead of returning IP of the given url this function outputs url what you typed. For example, we can try a url which is redirected to another url then by using gethostbyname() function it only outputs same url. The reason is the URL doesn't resolve any ip address, so the browser automatically prepends "www" to the url. You can also replicate the same functionality in our code by adding "www" to the url,
  gethostbyname("www.example.com");

Now this returns IP of the given website. There is another function in php called "gethostbynamel ()". This function returns an array which consists list of ipv4 addresses of given url. You can get more info in phpmanual about this manual.

The topic on Php - How to get ip address of a domain is posted by - Math

Hope you have enjoyed, Php - How to get ip address of a domainThanks for your time

Tech Bluff