<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>
|