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

ip2The long() function converts IPV4 the string Internet Protocol to a long integer number.

Syntax

int ip2long ( string $ip_address )

Definition and Usage

It is used to convert ipv4Address converted to a long integer.

Return Value

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

Parameter

NumberParameter and Description
1

ip_address

It contains an IP address.

Online Example

Try the following example

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

Output Result

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

PHP HTTP Reference Manual