Try this one instead:
function iplongtostring($ip)
{
$ip=floatval($ip); // otherwise it is capped at 127.255.255.255
$a=($ip>>24)&255;
$b=($ip>>16)&255;
$c=($ip>>8)&255;
$d=$ip&255;
return "$a.$b.$c.$d";
}
整型一个 integer 是集合 Z = {..., -2, -1, 0, 1, 2, ...} 中的一个数。 参见任意长度整数(GMP),浮点数和任意精度数学库(BCMath)。 语法整型值可以用十进制,十六进制或八进制符号指定,前面可以加上可选的符号(- 或者 +)。 如果用八进制符号,数字前必须加上 0(零),用十六进制符号数字前必须加上 0x。 整数溢出如果给定的一个数超出了 integer 的范围,将会被解释为 float。同样如果执行的运算结果超出了 integer 范围,也会返回 float。
转换为整形要明示地将一个值转换为 integer,用 (int) 或 (integer) 强制转换。不过大多数情况下都不需要强制转换,因为当运算符,函数或流程控制需要一个 integer 参数时,值会自动转换。还可以通过函数 intval() 来将一个值转换成整型。 参见类型戏法。
add a note
User Contributed Notes
jmw254 at cornell dot edu
26-Aug-2006 01:14
Try this one instead:
rickard_cedergren at yahoo dot com
27-Jan-2005 05:15
When doing large subtractions on 32 bit unsigned integers the result sometimes end up negative. My example script converts a IPv4 address represented as a 32 bit unsigned integer to a dotted quad (similar to ip2long()), and adds a "fix" to the operation.
24-Dec-2003 02:18
Sometimes you need to parse an unsigned | ||||||