ip2long

(PHP 4 >= 4.0.0)

ip2long --  Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address.

Description

int ip2long (string ip_address)

The function ip2long() generates an IPv4 Internet network address from its Internet standard format (dotted string) representation.

Example 1. ip2long() Example


<?php
$ip = gethostbyname("www.php.net");
$out = "The following URLs are equivalent:<br>\n";
$out .= "http://www.php.net/, http://".$ip."/, and http://".ip2long($ip)."/<br>\n";
echo $out;
?>
     

This second example shows how to print a converted address with the printf() function :

Example 2. IP address displaying


<?php
$ip = gethostbyname("www.php.net");
printf ("%u\n", ip2long ($ip));
echo $out;
?>
     

See also: long2ip()