From:             
Operating system: Windows XP SP3
PHP version:      5.3.7
Package:          Variables related
Bug Type:         Bug
Bug description:Superglobal variable variables with ${expression} in non-global 
scope

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 bug report at https://bugs.php.net/bug.php?id=55493&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=55493&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=55493&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=55493&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=55493&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=55493&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=55493&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=55493&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=55493&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=55493&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=55493&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=55493&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=55493&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=55493&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=55493&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=55493&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=55493&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=55493&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=55493&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=55493&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=55493&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=55493&r=mysqlcfg

Reply via email to