I need to check if value is defined as anything, including null. isset treats null values as undefined and returns false. Take the following as an
isset
false
is_null($bar) returns true, since it has no values at all. Alternatively, you can use:
is_null($bar)
if(isset($bar) && is_null($bar)) // returns false
to check if $bar is defined and will only return true if:
$bar
$bar = null; if(isset($bar) && is_null($bar)) // returns true