Modification of integer processing mechanism


1. Invalid octal numbers will report a compilation error

Invalid octal numbers (including numbers greater than 7) will report a compilation error. For example, the following code will report an error:

$i = 0781; // 8 is not a valid octal digit!

Old versions of PHP will ignore invalid numbers.

2. Negative displacement positions will generate exceptions

 var_dump(1 >> -1);
 // ArithmeticError: Bit shift by negative number

3. If the left displacement exceeds the number of digits, it will return 0

var_dump(1 << 64); // int(0)

Old version of PHP running results and cpu Architecture matters. For example, x86 will return 1.

4. If the right displacement exceeds, 0 or -1 will be returned.

var_dump(1 >> 64);  // int(0)
var_dump(-1 >> 64); // int(-1)