Warning: include(../lntop.php) [function.include]: failed to open stream: No such file or directory in /var/www/prime/data/www/prime-speed.ru/Manual_PHP_4/f/ip2long.html on line 19

Warning: include() [function.include]: Failed opening '../lntop.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/prime/data/www/prime-speed.ru/Manual_PHP_4/f/ip2long.html on line 19

Warning: include(../levoe_menu.php) [function.include]: failed to open stream: No such file or directory in /var/www/prime/data/www/prime-speed.ru/Manual_PHP_4/f/ip2long.html on line 46

Warning: include() [function.include]: Failed opening '../levoe_menu.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/prime/data/www/prime-speed.ru/Manual_PHP_4/f/ip2long.html on line 46



Учебник РНР
НазадВперёд

ip2long

(PHP 4)

ip2long - конвертирует строку, содержащую адрес (IPv4) Internet Protocol, в подходящий адрес.

Описание

int ip2long (string ip_address)

Функция ip2long() генерирует IPv4 Internet сетевой адрес из стандартного представления в Internet-формате (строки с точками).
Пример 1. ip2long()
<?php
$ip = gethostbyname("www.example.com");
$out = "The following URLs are equivalent:<br>\n";
$out .= "http://www.example.com/, http://".$ip."/, and http://".sprintf("%u",ip2long($ip))."/<br>\n";
echo $out;
?>

Примечание: поскольку PHP-тип integer является знаковым, а многие IP-адреса дают отрицательные целочисленные значения, вам необходимо использовать форматировщик "%u" sprintf() или printf() для получения строкового представления беззнаковых IP-адресов.

Во втором примере показано, как напечатать конвертированный адрес с помощью функции printf().
Пример 2. Отображение IP-адреса
<?php
$ip = gethostbyname("www.example.com");
printf("%u\n", ip2long($ip));
echo $out;
?>

См. также long2ip().


Назад Оглавление Вперёд
getservbyport Вверхlong2ip


Warning: include(../pravoe_menu.php) [function.include]: failed to open stream: No such file or directory in /var/www/prime/data/www/prime-speed.ru/Manual_PHP_4/f/ip2long.html on line 152

Warning: include() [function.include]: Failed opening '../pravoe_menu.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/prime/data/www/prime-speed.ru/Manual_PHP_4/f/ip2long.html on line 152

Rambler's Top100
© 2009 Тест скорости интернета |  Boont.Ru

Warning: include(../lnbottom.php) [function.include]: failed to open stream: No such file or directory in /var/www/prime/data/www/prime-speed.ru/Manual_PHP_4/f/ip2long.html on line 278

Warning: include() [function.include]: Failed opening '../lnbottom.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/prime/data/www/prime-speed.ru/Manual_PHP_4/f/ip2long.html on line 278