The unexpected behaviour of isset() for variables which have the value NULL caused a bit of a headache today. One would assume if a variable has any value assigned testing this variable with isset() would return true. This is the case except when the variable has the value NULL assigned. Here a quick example:
$a = 1; var_dump(isset($a)); $a = null; var_dump(isset($a));
This outputs:
bool(true) bool(false)
The PHP documentation for isset() states:
isset() will return
FALSE
if testing a variable that has been set toNULL
.
Kunststube.net has a very good overview on isset() and empty() in combination with NULL .