This exple gets the host name using a function gethostbyname, that prints out ip address of the server.. This is also an example of comparing isset with empty functions.

<html>
<head>
<title> hostname validator </title>
</head>
<body>
<form method="POST" action="network_gethostbyname.php">

<p><input type="text" name="T1" size="20"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>


<?php
//$host= "frontiersoft.net";
$host= $_POST['T1'];
if(isset($host))
{
echo $result.'you see this line isset counts null values<br>';
$result = gethostbyname($host);
echo $result." is default <br/>";
}

?>
<?php
//$host = 0;

// Evaluates to true because $var is empty
if (empty($host)) {
echo '$host is empty <br>';
}
else
{
echo gethostbyname($host)."<br/>";
}

?>

</body>
</html>
 

if you just click on submit, gethostbyname function prints the localhost.