Home > Backend Development > PHP Tutorial > Bit operations in php

Bit operations in php

不言
Release: 2023-03-23 18:52:01
Original
1637 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template