PHP: Get IP address of a domain or URL
With just a single statement it is possible to find out the IP address of a domain or URL.
Simply use the gethostbyname() function in PHP to get the IP address.
See the example below to find out how to use this function.
You find the output of the code below the code.
$domain = "Computer-Masters.net";
$ip = gethostbyname($domain);
echo "Domain: ".$domain;
echo "IP: ".$ip;
The output of the code is the following:
You can also simply use this form to get the IP of a hostname:
Get IP of a URL
You still have questions?
Feel free to use our comment form that is also available for non-registered users.