Bitshift Operators¶
Bitshift operators <<
and >>
move bits within an integer. The bits are shifted by an number of position, to the right or to the left. They are equivalent to multiplying or dividing by a power of 2.
<?php
$a = 3; // binary : 11
echo $a >> 1; // binary : 1 (the last 1 is lost)
echo $a << 2; // binary : 1100
?>
See also Are Bitwise Operators Still Relevant in Modern PHP?
Related : Logical Operators, Bitwise Operators