Check if value isset and null

ShelbyS

New Member
I need to check if value is defined as anything, including null. \[code\]isset\[/code\] treats null values as undefined and returns \[code\]false\[/code\]. Take the following as an example:\[code\]$foo = null;if(isset($foo)) // returns falseif(isset($bar)) // returns falseif(isset($foo) || is_null($foo)) // returns trueif(isset($bar) || is_null($bar)) // returns true, raises a notice\[/code\]Note that \[code\]$bar\[/code\] is undefined.I need to find a condition that satisfies the following:\[code\]if(something($bar)) // returns false;if(something($foo)) // returns true;\[/code\]Any ideas?
 
Back
Top