Bug #68162 [Com]: isset($$varname) always true
| From: | nikic@php.net | Date: | Mon, 06 Oct 2014 17:03:18 +0000 |
| Subject: | Bug #68162 [Com]: isset($$varname) always true | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187895@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68162&edit=1
ID: 68162
Comment by: nikic@php.net
Reported by: pegasus at vaultwiki dot org
Summary: isset($$varname) always true
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: Centos 6 64-bit
PHP Version: master-Git-2014-10-06 (Git)
Block user comment: N
Private report: N
New Comment:
I can't repro this.
Previous Comments:
------------------------------------------------------------------------
[2014-10-06 04:51:33] pegasus at vaultwiki dot org
Description:
------------
It seems that isset (likely others like unset, empty, etc) cannot properly resolve variably-named
variables and simply returns true.
Test script:
---------------
function testWrapper()
{
foreach (array(
'testvar1',
'testvar2'
) AS $varname)
{
if (!isset($$varname))
{
echo "\nSetting $varname\n";
$$varname = array();
}
var_dump($$varname);
}
}
testWrapper();
Expected result:
----------------
Setting testvar1
array(0) {}
Setting testvar2
array(0) {}
Actual result:
--------------
NULL
NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68162&edit=1