$v = 04555720201; echo $v;
恩。。。。输出结果是632791169
起初以为是溢出的,最后发现是因为以0开头的整型会被认为八进制。
查了点资料做备份。
1.Syntax:
Integers can be specified in decimal (base 10), hexadecimal (base 16), or octal (base
notation, optionally preceded by a sign (- or +).
To use octal notation, precede the number with a 0 (zero). To use hexadecimal notation precede the number with 0x.
decimal : [1-9][0-9]*
| 0hexadecimal : 0[xX][0-9a-fA-F]+
octal : 0[0-7]+
integer : [+-]?decimal
| [+-]?hexadecimal
| [+-]?octal
2.溢出overflow
If PHP encounters a number beyond the bounds of the integer type, it will be interpreted as a float instead. Also, an operation which results in a number beyond the bounds of the integer type will return a float instead.
32位系统是2^32-1(?)
注:Mysql里的有符号整型是-2147483648 到2147483647(与PHP相同),无符号的是0 到4294967295
2010.01.08更新3. cookie不能设置为100年哇,虽然想做永久不过期,但是不必须设100年哇,100年会导致PHP溢出的。。。。