Michael Lazzaro wrote: > Agreed: the value of comparing a boolean with anything else is not > particularly sensible in *any* language.
It isn't particularly unsensible in PHP. PHP only has one equality operator. If its operands are of different types then it casts one operand to match the other, choosing these types in order of preference: bool int float string That means that comparing a bool with something else first casts the something else to a bool, so the comparison works: $int = 3; if ($int == true) { echo 'This gets printed.'; } However I am certainly _not_ suggesting this should be done in Perl. In particular the automatic casting of strings to integers can get 'awkward': $x = 'cat' $y = 0; if ($x == 'cat') { echo 'This gets printed.'; } if ($y == 'cat') { echo 'So does this!'; } The 'solution' offered by PHP is the equivalence operator, which only returns true if its operands have the same type and same value: if ($y === 'cat') { echo "This doesn't print."; } However that then breaks other things: $a = '2'; # strings, because have been read from a user $b = '3'; $total = '5'; if ($a + $b === $total) { echo "But this doesn't print either."; } > Anyone who does it deserves what they get. ;-) Exactly. Smylers