Journal tmhsiao's Journal: null == 0...
Looking at the following code:
if ($foo == 1) {
echo "Foo is 1";
}
elseif ($foo == 0) {
echo "Foo is 0";
}
If $foo is not defined (as in the case of, say, an unposted $_POST variable), $foo == 0 evaluates as true.
All null values equal 0 apparently, forcing any specific zero-check to look as follows:
if ($foo == 1) {
echo "Foo is 1";
}
elseif (($foo == 0) && (is_numeric($foo))) {
echo "Foo is 0";
}
Sometimes I hate this language.
null == 0... More Login
null == 0...
Slashdot Top Deals