PHP » PYTHON |
login |
register |
about
|
from socket import inet_aton from struct import unpack def ip2long(ip_addr): return unpack("!L", inet_aton(ip_addr))[0] ip2long(PHP 4, PHP 5) ip2long — Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address Description
int ip2long
( string $ip_address
)
The function ip2long() generates an IPv4 Internet network address from its Internet standard format (dotted string) representation. ip2long() will also work with non-complete IP addresses. Read » http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/libs/commtrf2/inet_addr.htm for more info. Parameters
Return ValuesReturns the IPv4 address or FALSE if ip_address is invalid. Changelog
Examples
Example #1 ip2long() Example
<?php
Example #2 Displaying an IP address This second example shows how to print a converted address with the printf() function in both PHP 4 and PHP 5:
<?php
Example #3 IP validation ip2long() should not be used as the sole form of IP validation. Combine it with long2ip():
<?php
Notes
|
more
Recently updated
more
Most requested
more
Last requests
|