English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP basic tutorial

PHP advanced tutorial

PHP & MySQL

PHP reference manual

PHP ip2long() function usage and example

PHP HTTP  reference manual

The ip2long() function converts a string internet protocol (IPV4) to a long integer.

Syntax

int ip2long ( string $ip_address )

Definition and usage

It is used to convert an IPv4 address to a long integer.

Return value

 Returns the numeric representation of the IP address after conversion or FALSE if ip_address is invalid.

Parameter

Serial numberParameters and descriptions
1

ip_address

It contains an IP address.

Online example

Try the following example

<?php
   $ip = gethostbyname('ru.oldtoolbag.com');
   $out = "The following three URLs are equivalent:"
   \n";
   
   $out .= 'http://ru.oldtoolbag.com/, http://' . $ip . '/ 
      And http://' . sprintf("眻, ip2long($ip)) . "/"
   \n";
   
   echo $out;
?>

Output result

The following three URLs are equivalent:
http://ru.oldtoolbag.com/, http://39.107.75.220/, http://661343196/

PHP HTTP  reference manual