if($var == (2 || 3))
Several solutions have already been offered, so I'd just like to elaborate on why your attempt didn't work.
Actually, || is not a bitwise operator (as you say in the title), but a logical operator, treating the individual parts in their entirety as boolean values (true/false). I.e., since both 2 and 3 are true, 2 || 3 is true as well, and that's what you're comparing $var against. More precisely, you're comparing $var to 2, because the first true value is "returned" as is.
The respective bitwise operator would be |, which combines the corresponding individual bits of the values, i.e. 2 | 3 == 3, or 0b10 | 0b11 == 0b11. In other words, if($var == (2 | 3)) wouldn't work either for combining the tests the way you're thinking of, because if $var is 2, you'd compare it against 3, which is false, of course.
In reply to Re: comparison with bitwise operators
by Anonyrnous Monk
in thread comparison with bitwise operators
by alextor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |