2013/1/4 tamouse mailing lists <tamouse.lists@xxxxxxxxx> > Bit operators & and | are NOT and should NEVER be confused with > Logical operators && and ||: > > > <?php > /** > * Bit operators in PHP > */ > > $format = "Decimal: %2d Binary: %4b\n"; > > > $a = 4; > $b = 6; > > > echo "Variable \$a:\n"; > printf($format, $a, $a); > > echo "Variable \$b:\n"; > printf($format, $b, $b); > > $c = $a | $b; > echo "Result of OR bit operator\n"; > printf($format, $c, $c); > > $c = $a & $b; > echo "Result of AND bit operator\n"; > printf($format, $c, $c); > > ?> > > > OUTPUT: > ------- > > Variable $a: > Decimal: 4 Binary: 100 > Variable $b: > Decimal: 6 Binary: 110 > Result of OR bit operator > Decimal: 6 Binary: 110 > Result of AND bit operator > Decimal: 4 Binary: 100 > > > Bit operators are not comparing values, they're COMBINING values. > Technically spoken they're comparing bits, whereas boolean operators does the same, but treaten every value as a single bit. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- github.com/KingCrunch