Edit report at https://bugs.php.net/bug.php?id=55493&edit=1

 ID:                 55493
 Comment by:         larue...@php.net
 Reported by:        vovan-ve at yandex dot ru
 Summary:            Superglobal variable variables with ${expression} in
                     non-global scope
 Status:             Open
 Type:               Bug
 Package:            Variables related
 Operating System:   Windows XP SP3
 PHP Version:        5.3.7
 Block user comment: N
 Private report:     N

 New Comment:

when fetching a variable, the target symbol table is decided in compiling time, 
 
for the script above,  in compiling time, only const string "_SERVER" can be 
took consider as a SUPERVAR and assign the global symbol table as 
target_symbol_table.

the others `varname` only can be see in execution time, so Zend VM think it 
should be fetched from a local symbol table.

and the 'local symbol table' for the global scope statement is actual 'global 
symbol table', therefor it works 'as expected'.


Previous Comments:
------------------------------------------------------------------------
[2011-08-23 14:14:42] vovan-ve at yandex dot ru

Description:
------------
ONLY Superglobal variable variables does not work ONLY in non-global
scope and ONLY with non-constant expression. See test script.

I found Req 38527, but it does not describe the problem properly and
due to misunderstanding it has status Feature Request instead of Bug
(and also it is too old).

Test script:
---------------
// in global scope everything is right
$name = '_SERVER';
var_dump(
    isset(${'_SERVER'}),
    isset($$name),
    isset(${$name}),
    isset(${'_SER' . 'VER'}),
    isset(${'na' . 'me'})
);
echo PHP_EOL;

// but outside of global scope there is a trouble
function f() {
    $name = '_SERVER';
    var_dump(
        isset(${'_SERVER'}),
        isset($$name),
        isset(${$name}),
        isset(${'_SER' . 'VER'}),
        isset(${'na' . 'me'})
    );
}
f();

Expected result:
----------------
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)

bool(true)
bool(true)
bool(true)
bool(true)
bool(true)

Actual result:
--------------
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)

bool(true)
bool(false)
bool(false)
bool(false)
bool(true)


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55493&edit=1

Reply via email to