3
There is a difference between ^ and &~, but in this case there is no difference.
是有區別的^ & ~,但在這種情況下沒有區別。
^ means XOR, so bits that are set in either the left operand or the right operand but not both are set in the result. &~ means AND NOT, so bits that are set in the left operand but not in the right operand are set in the result.
^意味着XOR,所以部分設置在右邊左邊的操作數或操作但不都是在結果集。&~表示是否,所以結果中設置了左操作數而不是右操作數中的位。
If we looked at the following numbers, there would be a difference:
如果我們看下面的數字,就會有不同:
$a = 0b1010; // decimal 10
$b = 0b0001; // decimal 1
$a ^ $b results in 0b1011 (decimal 11) whereas $a & ~$b results in 0b1010 (decimal 10).
$ ^ $ b導致0 b1011(十進制11)而& ~ b導致0美元b1010(十進制10)。
However, E_ALL is effectively 0b11111111 (i.e. all the bits are set; it's actually rather more than 8 bits). So XOR is effectively the same as AND NOT.
然而,E_ALL是有效的0b11111111(即所有位都被設置;它實際上比8位多)。所以XOR實際上是相同的,而不是。
$a = 0b11111111; // decimal 255
$b = 0b00000100; // decimal 4
$a ^ $b gives 0b11111011 (decimal 251), as does $a & ~$b.
$ ^ $ b給0 b11111011(十進制251),和$ & ~ $ b。