Determining the Hostname of a Remote IP : gethostbyaddr « DNS « PHP






Determining the Hostname of a Remote IP

 
<?php

    $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

    if($hostname === $_SERVER['REMOTE_ADDR']) {

        echo "The host name could not be resolved.<BR/>\n";

    } else {

        echo "The host name is: $hostname<BR/>\n";

    }
?>
  
  








Related examples in the same category

1.Using gethostbyaddr() to Get a Hostname