BUG: sprintf(%u) and ip2long

From: Date: Tue, 14 Oct 2003 18:49:27 +0000
Subject: BUG: sprintf(%u) and ip2long
Groups: php.general 
Request: Send a blank email to php-general+get-166101@lists.php.net to get a copy of this message
Could be my not understanding of something, but I think there is a bug in using ip2long() and sprintf(%u) as indicated on this page: http://us4.php.net/manual/en/function.ip2long.php Look at the example below: //this conversion seems broken // $startIP_long = sprintf("%u",ip2long($QRange1)); // $endIP_long = sprintf("%u",ip2long($QRange2)); $startIP_long = ip2long($QRange1); $endIP_long = ip2long($QRange2); echo "QRange1 = ".$QRange1." and QRange2 = ".$QRange2."<BR>"; echo "startIP_long = ".$startIP_long." and endIP_long = ".$endIP_long."<BR>"; echo "startIP_long = ".long2ip($startIP_long)." and endIP_long = ".long2ip($endIP_long)."<BR>"; The first //commented block will give: QRange1 = 192.169.12.40 and QRange2 = 192.169.20.40 startIP_long = 3232304168 and endIP_long = 3232306216 startIP_long = 127.255.255.255 and endIP_long = 127.255.255.255 (wtf did the "127.255.255.255" come from?!) While the second works properly... QRange1 = 192.169.12.40 and QRange2 = 192.169.20.40 startIP_long = -1062663128 and endIP_long = -1062661080 startIP_long = 192.169.12.40 and endIP_long = 192.169.20.40

« previous php.general (#166101) next »