How to know if a PHP variable exists, even if its value is NULL? -
$a = null; $c = 1; var_dump(isset($a)); // bool(false) var_dump(isset($b)); // bool(false) var_dump(isset($c)); // bool(true)
how can distinguish $a
, exists has value of null
, “really non-existent” $b
?
use following:
$a = null; var_dump(true === array_key_exists('a', get_defined_vars()));
Comments
Post a Comment