Bug #68162 [Opn->Csd]: isset($$varname) always true
| From: | nikic@php.net | Date: | Mon, 06 Oct 2014 18:39:39 +0000 |
| Subject: | Bug #68162 [Opn->Csd]: isset($$varname) always true | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187897@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
Updated by: nikic@php.net
Reported by: pegasus at vaultwiki dot org
Summary: isset($$varname) always true
-Status: Open
+Status: Closed
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:
Automatic comment on behalf of nikic
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e24c24c1087c6405e842fdd7afcd84b224eb75bf
Log: Fix bug #68162: isset($$varname) always true
Previous Comments:
------------------------------------------------------------------------
[2014-10-06 18:01:40] pegasus at vaultwiki dot org
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;
####
------------------------------------------------------------------------
[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