Bug #54131 [NEW]: _SERVER, _ENV access via $$ shows Notice

From: Date: Wed, 02 Mar 2011 03:52:12 +0000
Subject: Bug #54131 [NEW]: _SERVER, _ENV access via $$ shows Notice
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-159137@lists.php.net to get a copy of this message
From:             
Operating system: Debian
PHP version:      5.3.5
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:_SERVER, _ENV access via $$ shows Notice

Description:
------------
If you access $_ENV or $_SERVER the indirect way, via ${'_SERVER'} you get
an 
E_NOTICE message. Please see my test scripts.

Test script:
---------------
Producing the bug:

<?php
error_reporting(E_ALL | E_STRICT);
$x = '_SERVER';
print_r($$x); // Notice: Undefined variable: _SERVER
?>

Workaround with dummy function which "touches" the variable:

<?php
error_reporting(E_ALL | E_STRICT);

function dummy($dummy) {}
dummy($_SERVER); // "Touch"

$x = '_SERVER';
print_r($$x); // Everything is OK!
?>

Expected result:
----------------
I don't expect an message that $_SERVER or $_ENV are not valid variables. I
kept 
searching for hours because I couldn't find any reason, why $_SERVER
disappears, 
but is visible in phpinfo(). I do not know why I have to "touch" these
super-
globals first, so that they get "active".


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



Thread (4 messages)

« previous php.bugs (#159137) next »