The example code is ok.
if ($xxx != false) {
echo 'xxxxxxxxxxx';
} else {
echo 'aaaaaaaaaaa';
}
// result: xxxxxxxxxxx
if ($xxx !== 0) {
echo 'xxxxxxxxxxx';
} else {
echo 'aaaaaaaaaaa';
}
// result: aaaaaaaaaaa
But this one confuses me
if ($xxx != 0) {
echo 'xxxxxxxxxxx';
} else {
echo 'aaaaaaaaaaa';
}
// result: aaaaaaaaaaa
$xxx is string, why this code returns me false? I have read the document http://www.php.net/manual/en/types.comparisons.php but still don't understand about it.