php 为空时为空?
I have a question regarding NULL
in PHP:
$a = '';
if($a == NULL) {
echo 'is null';
}
Why do I see is null when $a
is an empty string? Is that a bug?
What you're looking for is:
if($variable === NULL) {...}
Note the ===
.
When use ==
, as you did, PHP treats NULL, false, 0, the empty string, and empty arrays as equal.
相关文章