Edit report at https://bugs.php.net/bug.php?id=65652&edit=1
ID: 65652
Comment by: anon at anon dot anon
Reported by: kozak at eurosat dot cz
Summary: isset alternative
Status: Open
Type: Feature/Change Request
Package: *General Issues
Operating System: ALL
PHP Version: 5.5.3
Block user comment: N
Private report: N
New Comment:
echo array_key_exists('b', get_defined_vars()) ? "exists" : "doesn't exist";
Previous Comments:
------------------------------------------------------------------------
[2013-09-11 12:34:01] kozak at eurosat dot cz
Description:
------------
At the moment isset call return true only when variable is set and it is not
null.
But there is no way (or I do not find it so far), how to just test variable for
existance. So it will be perfect if there will be some other call (for eg:
exist)
or some parametr how to get this behaviour
More in example.
Test script:
---------------
$a = null;
$testOnlyExistence = true;
echo isset($b); // prints false;
echo isset($a); // prints false;
echo isset($a, $testOnlyExistence); // prints true;
echo isset($b, $testOnlyExistence); // prints false;
// or
echo exist($a); // prints true;
echo exist($b); // prints false;
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65652&edit=1