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

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -