php is null when empty? [duplicate]
As is shown in the following table, empty($foo)
is equivalent to $foo==null
and is_null($foo)
has the same function of $foo===null
. The table also shows some tricky values regarding the null
comparison. (ϕ denotes an uninitialized variables. )
empty is_null ==null ===null isset array_key_exists ϕ | T | T | F | F null | T | T | F | T "" | T | F | T | T [] | T | F | T | T 0 | T | F | T | T false | T | F | T | T true | F | F | T | T 1 | F | F | T | T \0 | F | F | T | T