Filed Under (PHP Code Samples) by Anoop on May-22-2007
Code (php)

<?php
$URL = 'www.yah.in';
$ip = gethostbyname($URL); // Get IP address from a URL
$out = "The following URLs are equivalent (for dedicated IP addresses only): ";
$out .= $URL.', http://' . $ip . '/ http://' . sprintf("%u", ip2long($ip)) . "";
echo $out;
echo "Your IP address: ".$_SERVER['REMOTE_ADDR'];
?>
 

You can also use long2ip() function to get ip address back from a long code.



Post a comment
Name: 
Email: 
URL: 
Comments: