• PHP Video Tutorials

PHP - Function ip2long



Syntax

int ip2long ( string $ip_address )

Definition and Usage

It used to convert ipv4 address to long integer.

Return Values

It Returns long integer or else shows a message as ip address is invalid.

Parameters

Sr.No Parameters & Description
1

ip_address

it contains a IP address.

Example

Try out following example

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

This will produce following result −

The following URLs are equivalent:
http://www.tutorialspoint.com/, http://72.21.91.8/, and http://1209359112/
php_function_reference.htm
Advertisements