Home  >  Article  >  Backend Development  >  Bit operations in php

Bit operations in php

不言
不言Original
2018-04-13 16:55:121606browse

The content shared with you in this article is about bit operations in PHP, which has certain reference value. Friends in need can refer to it

$a & $b And (bitwise AND) will set the bits in and that are both 1 to 1.
$a | $b Or (bitwise OR) will combine and Any bit that is 1 is set to 1.
$a ^ $b Xor (bitwise XOR) will combine The bit where one is 1 and the other is 0 is set to 1.
~ $a Not (bitwise negation) will be 0 in Bit is set to 1 and vice versa.
$a << $bShift left The bits in are shifted to the left times (each shift means "multiply by 2").
$a >> $b Shift right The bits in are shifted to the right times (each shift means "divide by 2").


The above is the detailed content of Bit operations in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn