A friend of mine recently showed my the following snippet
<?php
$a = 0;
$b = 'x';
if(FALSE == $a && $a == $b && $b == TRUE) {
echo 'WTF!?';
}
?>
which ouputs WTF!?
I understand why FALSE == $a
holds, because zero is considered to be FALSE
. I also understand why $b == TRUE
holds, because the string is not empty. But I didn't understand why $a == $b
is true, could somebody explain to me what type coercion rules play together here to get this rather amusing result?