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?
& is bitwise AND. See Bitwise Operators. Assuming you do 14 & 7:
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
2.1m questions
2.1m answers
60 comments
57.0k users