Domain name to IP address demo

Resolve all IPv4 addresses returned for a host

<?php
$addresses = gethostbynamel('example.com') ?: [];

foreach ($addresses as $address) {
    echo htmlspecialchars($address, ENT_QUOTES, 'UTF-8') . '<br>';
}
?>
https://www.

CAPTCHA challenge

Related DNS functions

gethostbyname() returns one IPv4 address, while gethostbynamel() returns all IPv4 addresses it finds for the host.

<?php
$ip = gethostbyname('example.com');
echo htmlspecialchars($ip, ENT_QUOTES, 'UTF-8');
?>

Mail exchanger records can be collected with getmxrr():

<?php
$mxHosts = [];
if (getmxrr('example.com', $mxHosts)) {
    foreach ($mxHosts as $host) {
        echo htmlspecialchars($host, ENT_QUOTES, 'UTF-8') . '<br>';
    }
}
?>

← gethostbyname() tutorial




Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer