ip2long
Description
The ip2long of Network for PHP converts a string containing an (IPv4) Internet Protocol dotted address into a long integer.
Syntax
ip2long( string $ip ): int|false
Parameters
ip
A standard format address.
Return
Returns the long integer or false if ip is invalid.
Examples
1 · ip
<? $hostname = "php.net"; $ip = gethostbyname($hostname); $return = ip2long($ip); echo $hostname . PHP_EOL . $ip . PHP_EOL . $return;
php.net 185.85.0.29 3109355549
2 · 32-bit systems
<? $hostname = "php.net"; $ip = gethostbyname($hostname); $return = ip2long($ip); if($return == -1 || $return === false) { echo "invalid"; } else { echo sprintf("%u", $return); }
3109355549
Links
Related
Network
- checkdnsrr
- closelog
- dns_check_record
- dns_get_mx
- dns_get_record
- fsockopen
- gethostbyaddr
- gethostbyname
- gethostbynamel
- gethostname
- getmxrr
- getprotobyname
- getprotobynumber
- getservbyname
- getservbyport
- header
- header_register_callback
- header_remove
- headers_list
- headers_sent
- http_clear_last_response_headers
- http_get_last_response_headers
- http_response_code
- inet_ntop
- inet_pton
- long2ip
- openlog
- pfsockopen
- setcookie
- setrawcookie
- socket_get_status
- socket_set_blocking
- socket_set_timeout
- syslog