PHP ip2long() Function
Example
Convert an IPv4 address into a long integer:
<?php
$ip = gethostbyname("www.w3schools.com");
$out = "The following URLs are
equivalent:<br>";
$out .= "https://www.w3schools.com/, https://" . $ip .
"/, and https://" . sprintf("%u", ip2long($ip)) . "/";
echo $out;
?>
Definition and Usage
The ip2long() function converts an IPv4 address into a long integer.
Syntax
ip2long(address)
Parameter Values
Parameter | Description |
---|---|
address | Required. Specifies a standard IP address |
Technical Details
Return Value: | A long integer. FALSE on failure |
---|---|
PHP Version: | 4.0+ |
PHP Changelog: | PHP 5.5: Before this version, on Windows, this function might return a
valid number even if the passed value was not an IPv4 address. PHP 5.2: PHP 5.5: Before this version, this function might return a valid number even if the passed value was not an IPv4 address. |
❮ PHP Network Reference