Using gethostbyaddr() to Get a Hostname : gethostbyaddr « DNS « PHP






Using gethostbyaddr() to Get a Hostname

 
<html>
<head>
<title>Using gethostbyaddr() to get a host name</title>
</head>
<body>
<div>
<?php
if ( ! empty( $_SERVER['REMOTE_HOST'] ) ) {
  print "Hello visitor at ".$_SERVER['REMOTE_HOST'];
} else if ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
   print "Hello visitor at ";
   print gethostbyaddr( $_SERVER['REMOTE_ADDR'] );
} else {
  print "Hello you, wherever you are";
}
?>
</div>
</body>
</html>
  
  








Related examples in the same category

1.Determining the Hostname of a Remote IP