How to Get IP Address Of Website in PHP
Posted on: March 01, 2021 by Ariessa Norramli
In this article, you will learn how to get the IP address of a website in PHP.
Let’s say you want to find out the IP address of Codesource.io’s website. You need to know the URL, which is code-source.tempurl.host
Get IP Address Of Website in PHP
In order to get the IP address of a website, you can use the gethostbyname()
method.
// Get IP address of a URL
$ip_address = gethostbyname("code-source.tempurl.host");
// Display the IP address
echo "IP Address of code-source.tempurl.host is ".$ip_address;
// IP Address of code-source.tempurl.host is 172.67.153.44
Note: The gethostbyname()
method functions by returning the IPV4 address of the supplied URL or hostname.
Share on social media
//