Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: long2ip - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

openlog" width="11" height="7"/> <ip2long
Last updated: Thu, 31 May 2007

view this page in

long2ip

(PHP 4, PHP 5)

long2ip — (IPv4) インターネットアドレスをインターネット標準ドット表記に変換 します。

説明

string long2ip ( int $proper_address )

関数long2ip() は、適当なアドレス表現からドット 表記(例:aaa.bbb.ccc.ddd)のインターネットアドレスを生成します。

ip2long()も参照ください。



openlog" width="11" height="7"/> <ip2long
Last updated: Thu, 31 May 2007
 
add a note add a note User Contributed Notes
long2ip
Gabriel Malca
17-Mar-2006 10:01
If the function doesn't exist:

<?
   
if (!function_exists("long2ip")) {
        function
long2ip($long) {
           
// Valid range: 0.0.0.0 -> 255.255.255.255
           
if ($long < 0 || $long > 4294967295) return false;
           
$ip = "";
            for (
$i=3;$i>=0;$i--) {
               
$ip .= (int)($long / pow(256,$i));
               
$long -= (int)($long / pow(256,$i))*pow(256,$i);
                if (
$i>0) $ip .= ".";
            }
            return
$ip;
        }
    }
?>
randomize at randomizer dot com
28-Jan-2006 02:51
Random ip address! (4294967295 is 255.255.255.255)

long2ip(rand(0, "4294967295"))
flobee
14-Feb-2005 07:50
when importing ip-ranges to a mysql database using an INT(10) field - NOTE: that you will get problems when using intval() function!

copied from "cleong" : 02-Oct-2001 02:21
intval() handles overflow differently depending on the type of the argument.
<?php
// intval('10000000000') = 2147483647
// intval(1e10) = 1410065408
?>
Tom Crosley
17-Feb-2003 06:13
I wanted to be able to pass an IP address in a URL always as an unsigned int.  I then converted it back as shown below:

$ip_addr = "192.168.100.25";  // example IP address that converts to neg #

$s32int = ip2long($ip_addr);

$us32str = sprintf("%u",$s32int);               // convert to unsigned string

// display orig IP address, signed 32 bit version, unsigned 32 bit ver,
// finally converted back to IP addr

printf("%s ,%d, %s, %s", $ip_addr, $s32int, $us32str,
         long2ip(-(4294967296-$us32str)));

// tested on Linux/Apache PHP 4.1.2

openlog" width="11" height="7"/> <ip2long
Last updated: Thu, 31 May 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites