I am confused with &
and &&
. I have two PHP books. One says that they are same, but the another says they are different. I thought they are same as well.
Aren't they same?
Answer
&
is bitwise AND. See Bitwise Operators. Assuming you do 14 & 7
:
14 = 1110
7 = 0111
---------
14 & 7 = 0110 = 6
&&
is logical AND. See Logical Operators. Consider this truth table:
$a $b $a && $b
false false false
false true false
true false false
true true true
No comments:
Post a Comment