The manual says is_null returns a TRUE/FALSE.
http://php.net/manual/en/function.is-null.php
Why does this return a 1? I expected “TRUE”.
$_SESSION['logged_on'] = null;
if (is_null($_SESSION['logged_on'])) {
echo is_null($_SESSION['logged_on']) . '<br/>';
}
exit;
When you echo a boolean, it is implicitly typecast to a string, and PHP decided that true would convert to “1” and false to “”.
Cups
4
$b=false;
var_dump($b);
// boolean false
Use var_dump() to test expectations - shows value and type.
Thanks Cups and John_Betong