What does >> mean in PHP?

后端 未结 8 1898
天涯浪人
天涯浪人 2021-02-19 05:13

Consider:

echo 50 >> 4;

Output:

3

Why does it output 3?

8条回答
  •  天涯浪人
    2021-02-19 06:04

    It's called a right shift. 'The bits of the left operand are shifted right by the number of positions of the right operand. The bit positions vacated on the left are filled with the sign bit, and bits shifted out on the right are discarded.'

    Information can be found on it here: http://php.comsci.us/etymology/operator/rightshift.php

提交回复
热议问题