The bitwise and mainly is the binary number operation.
The code is as follows:
Copy CodeThe code is as follows:
$a = 1;
$b = 2;
$c = $a ^b;
echo $c//3
?>
This is not a purely additive relationship.
Decimal 1 converted to binary 00000001
Decimal 2 converted to binary 00000010
The bitwise ^ 00000011//Is different is counted as 1 ^_^
And then
Copy CodeThe code is as follows:
$a = 1;
$b = 2;
echo $a & $c; 1
?>
Decimal 3 converted to binary 00000011
Decimal 1 converted to binary 00000001
Bitwise & 00000001//Is the same as each single digit, otherwise it will be counted as 0
Finally introduce the following usage; The bitwise & return value is meaningless. It is mainly used to determine if $ A is present in $c//permission usage is much more.
Copy CodeThe code is as follows:
$my _privilege = 15; 1+2+4+8 has full privileges
$Pri = ";
$privilege _arr = Array (8=> ' increase ', 4=> ' delete ',2=> ' change ',1=> ');
foreach ($privilege _arr as $k = + $v) {
$k & $my _privilege && $Pri. = ' I have '. $v. ' Power
';
}
Echo $Pri;
?>
http://www.bkjia.com/PHPjc/728104.html www.bkjia.com true http://www.bkjia.com/PHPjc/728104.html techarticle The bitwise and mainly is the binary number operation. The code is as follows: Copy the code as follows: PHP $a = 1; $b = 2; $c = $a ^b; echo $c//3? Here is not the simple addition of the decimal 1 conversion into ...