Edit report at https://bugs.php.net/bug.php?id=60944&edit=1
ID: 60944 Comment by: phpmpan at mpan dot pl Reported by: lampacz+php at gmail dot com Summary: Unable to detect if variable exists vs. is null Status: Open Type: Feature/Change Request Package: Variables related Operating System: Linux PHP Version: 5.3.9 Block user comment: N Private report: N New Comment: What is the rationale for introducing such function? Can you provide any real-life example when it is neccessary to distinguish between an undefined global variable and a global variable set to `NULL`? The question is important, as use of global variables is getting less popular. Adding a new function, that will duplicate already existing functionality (proposed by Laruence), is IMHO not a good idea. Previous Comments: ------------------------------------------------------------------------ [2012-02-01 10:39:28] lampacz+php at gmail dot com Marvelous. Sugestion for new function: is_defined(mixed $var) which internally return array_key_exists($var, get_defined_vars()); ? Thank you for. ------------------------------------------------------------------------ [2012-02-01 09:54:15] larue...@php.net <?php $a = null; var_dump(array_key_exists('a', get_defined_vars())); //or $GLOBALS ?> ------------------------------------------------------------------------ [2012-02-01 08:05:10] lampacz+php at gmail dot com Description: ------------ There is no difference between $x = NULL and unset($a). So i'm unable to detect if variable was defined (so it can be defined and be filled with null) http://www.php.net/manual/en/types.comparisons.php Table Comparisons of $x with PHP functions, rows 2 - 4 gives same results Expected result: ---------------- Different results for undefined variables and null variables ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60944&edit=1