I read PHP docs like Juggling and Booleans, but I still don't understand why this comparison is being evaluated as true. My [wrong] understanding tells me that in the if statement below, the integer 0 is considered FALSE and "a", being a non-empty string, is considered TRUE. Therefore, I expected this comparison to resolve to FALSE == TRUE and, ultimately, FALSE. In what part have I been mistaken?
<?php
if(0 == "a"){
$result = "TRUE";
}else{
$result = "FALSE";
}
?>
http://codepad.viper-7.com/EjxBF5
source
share