$result = gethostbyname('plus2net.com');
echo $result;
This is the ip address of the host server of plus2net.com.
$result = gethostbyname('plus2net.com');
echo $result;
echo "<br>";
echo gethostbyaddr($result);
The output of the above code is
74.53.25.146
4runner.websitewelcome.com
$result = gethostbynamel('google.com');
print_r($result);
The output of above code is here
Array ( [0] => 74.125.67.100 [1] => 74.125.127.100 [2] => 74.125.45.100 )
$domain = "example.com";
$ip = gethostbyname($domain);
if ($ip === $domain) {
echo "Invalid domain or no IP found.";
} else {
echo "Domain resolves to: " . $ip;
}
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.