php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50929 Incorrect initialization of $_SERVER
Submitted: 2010-02-03 18:12 UTC Modified: 2010-02-03 18:42 UTC
From: t-bader at gmx dot net Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.3.1 OS: Windows Vista/7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: t-bader at gmx dot net
New email:
PHP Version: OS:

 

 [2010-02-03 18:12 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-03 18:42 UTC] jani@php.net
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..)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Dec 07 12:00:02 2025 UTC