Home -
PHP-
Get Host Name
This script shows how to get a host name given an ip address when a web page is loaded.
/*
FluidCoding - Get Host Name
Author: Brian Sonnie
*/
<?php
$ip=$_SERVER['REMOTE_ADDR'];
$hostName = gethostbyaddr($ip);
$echo $hostName;
?>
Output
ec2-3-145-170-164.us-east-2.compute.amazonaws.com