I’ve got the following code:
print "\n1 & 11\n";
var_dump(1 & 11);
print "\n 2 & 222\n";
var_dump(2 & 222);
Why is the first result 1 ? And why is the second result 2?
The PHP Web site says that 2 & 222 (for example) should give me back a boolean value:
For example, $a & $b == true evaluates the equivalency then the bitwise and; while ($a & $b) == true evaluates the bitwise and then the equivalency.”
I don’t get it, how can 2 & 222 be 2 ?
In bits:
The
&operator returns all bits set to 1 in both numbers. So: