Bitwise Operators in PHP
PHP Bitwise Operators are used to perform operations on individual bits of binary numbers. These operators work on integers and convert them into binary form to perform operations.
There are six Bitwise Operators in PHP:
- & (Bitwise AND): Returns a binary number where each bit is 1 only if the corresponding bits of both operands are 1.
- | (Bitwise OR): Returns a binary number where each bit is 1 if either of the corresponding bits of both operands is 1.
- ^ (Bitwise XOR): Returns a binary number where each bit is 1 if the corresponding bits of both operands are different.
- ~ (Bitwise NOT): Returns the complement of the binary number. Each 1 becomes 0 and each 0 becomes 1.
- << (Left Shift): Shifts the bits of the left operand to the left by the number of positions specified in the right operand.
- (Right Shift): Shifts the bits of the left operand to the right by the number of positions specified in the right operand.
These operators are commonly used in programming to manipulate binary data and flags.
Apply for PHP Certification!
https://www.vskills.in/certification/certified-php-developer