Bitwise Operators in PHP

And Bit Operator : &
usage ( $x & $y ), Bits that are set in both $x and $y are set.

Or bit operator ( inclusive or ) : |
usage ( $x | $y ), Bits that are set in either $x or $y are set.

Xor bit operator ( exclusive or ) : ^
usage ( $x ^ $y ), Bits that are set in $x or $y but not both are set.

Not bit operator : ~
usage ( ~$x ), Bits that are set in $x are not set, and viceversa.

Shift Left bit operator : <<
usage ( $x << $y ), Shift the bits of $x $y steps to the left (each step means “multiply by two”)

Shift right bit operator : >>
usage ( $x >> $y ), Shift the bits of $x $y steps to the right (each step means “divide by two”)

Share
Share
Share