Bug #68162 [Com]: isset($$varname) always true
| From: | pegasus at vaultwiki dot org | Date: | Mon, 06 Oct 2014 18:01:40 +0000 |
| Subject: | Bug #68162 [Com]: isset($$varname) always true | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187896@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: pegasus at vaultwiki dot org
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:
Strange. I thought I was going crazy for a bit, then I tried messing around with actually trying to
use the arrays created by the test. The testWrapper above indeed works normally on its own, but add
the following immediately after the foreach loop in testWrapper:
####
$testvar1 = array_merge($testvar1, array());
$testvar2[] = true;
####
Previous Comments:
------------------------------------------------------------------------
[2014-10-06 17:03:18] nikic@php.net
I can't repro this.
------------------------------------------------------------------------
[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