Sunday, December 1, 2019

PHP isset() vs empty() vs is_null()

Value of variable ($var)isset($var)empty($var)is_null($var)
“” (an empty string)bool(true)bool(true)
” ” (space)bool(true)
FALSEbool(true)bool(true)
TRUEbool(true)
array() (an empty array)bool(true)bool(true)
NULLbool(true)bool(true)
“0” (0 as a string)bool(true)bool(true)
0 (0 as an integer)bool(true)bool(true)
0.0 (0 as a float)bool(true)bool(true)
var $var; (a variable declared, but without a value)bool(true)bool(true)
NULL byte (“\ 0”)bool(true)