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 th开发者_开发技巧e variable is null with they all return false?
Use type comparison.
$somevar === null
You can use either is_null() or use type comparison (===). They're virtually the same, except that type comparison will be slightly faster (by slightly I mean so abysmal that it almost doesn't matter).
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)
精彩评论