第一个示例向正数方向移位,结果为 4,但第二个示例向负数方向移位,结果为 ArithmeticError(此示例对于左移位相同)
<?php
$shif =1;
$number = 8;
$result = $number >> $shif;
echo $result; //// 1000 >> 01000 = 4
$shif =-1;
$number = 8;
$result = $number >> $shif;
////结果是 ArithmeticError
?>
(PHP 7,PHP 8)
第一个示例向正数方向移位,结果为 4,但第二个示例向负数方向移位,结果为 ArithmeticError(此示例对于左移位相同)
<?php
$shif =1;
$number = 8;
$result = $number >> $shif;
echo $result; //// 1000 >> 01000 = 4
$shif =-1;
$number = 8;
$result = $number >> $shif;
////结果是 ArithmeticError
?>