Can I use functions like is_integer(), is_string(), and other like them as a reliable check to see if the variable is null? I guess what I am asking is if the variable is null with they all return false?
3 Answers
Use type comparison.
$somevar === null
1 Comment
KingCrunch
Same as with
is_null(): Requires the existence of the variable (isset()).All of the is_*() functions tests the type of a value, thats theire main purpose. To test, if a variable is null, just test it ;)
is_null($var)
2 Comments
tereško
and keep in mind that is_null() means that it already passed isset()
KingCrunch
You're right, but as far as I know thats required in any case.
nullyou can conclude thatis_string()gives youfalse. But ifis_string()gives youfalse, the variable is not necessarynull.... so no, you cannot use to check them whether a variable isnull.