#50929 [Opn->Bgs]: Incorrect initialization of $_SERVER
ID: 50929
Updated by: jani@php.net
Reported By: t-bader at gmx dot net
-Status: Open
+Status: Bogus
Bug Type: Variables related
Operating System: Windows Vista/7
PHP Version: 5.3.1
New Comment:
You have just discovered JIT initialization of superglobals:
http://www.php.net/manual/en/ini.core.php#ini.auto-globals-jit
(note the Warning there..)
Previous Comments:
------------------------------------------------------------------------
[2010-02-03 18:12:12] t-bader at gmx dot net
Description:
------------
The manual says that Superglobals can be referenced by variable
variables in global scope.
For the $_SERVER superglobal does this only work at it first "normal"
usage.
<?php
$Superglobal = '_SERVER';
var_dump($$Superglobal);
?>
Outputs: NULL
But if i use the $_SERVER Variable after the var_dump(); the
var_dump()s output is correct:
<?php
$Superglobal = '_SERVER';
var_dump($$Superglobal);
$_SERVER;
var_dump($$Superglobal);
?>
Both var_dump()s output the whole $_SERVER array. If i remove the line
with $_SERVER; both var_dump()s output is NULL.
Reproduce code:
---------------
<?php
$Superglobal = '_SERVER';
var_dump($$Superglobal);
?>
Expected result:
----------------
Array containing the $_SERVER variables
Actual result:
--------------
NULL
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50929&edit=1
Thread (2 messages)