|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2006-01-15 12:12 UTC] derick@php.net
  [2007-08-20 12:41 UTC] vrana@php.net
  [2007-08-26 22:40 UTC] postings-php-bug at hans-spath dot de
  [2007-08-28 01:00 UTC] phpdoc at lists dot php dot net
 | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 19:00:02 2025 UTC | 
Description: ------------ environment: generic apache 2.0.55 / php 5.1.2 on linux (can reproduce with 5.0.5 on solaris9; it's not the os) yes, i've read the "variable variable references to superglobals aren't supported in functions"; this isn't in a function, and the behavior is very very strange. see attached code. the var-var-refs to $_SERVER works as expected IF AND ONLY IF that superglobal is referred to elsewhere in the code by its real name -- anywhere in the code is fine, even after the var-var-ref. this behavior suggests that the $_SERVER superglobal isn't instantiated (or made available) if the interpreter decides (wrongly) that it's not necessary. the parser does complain thusly: PHP Warning: Invalid argument supplied for foreach() in /home/web/docs/bug.php on line 11 Reproduce code: --------------- <? // works as expected if the following line is uncommented // if(is_array($_SERVER)) echo ''; echo "<html><table border=1 cellpadding=2>"; foreach(array( "_GET" => "#f0c0f0", "_POST" => "#f0c0c0", "_SESSION" => "#c0f0f0", "_SERVER" => "#f0f0c0") as $a => $c) { echo "\n<tr width=100% bgcolor=#c0c0c0><td colspan=2 align=right>$a</td></tr>"; foreach(${$a} as $k => $v) if($k) echo "\n<tr><td bgcolor=$c>$k</td><td bgcolor=$c>$v</td></tr>"; } echo "\n</table></html>"; ?> Expected result: ---------------- should have a table of all variables related to the request (i use this bit of code where i catch errors, it tends to be helpful). Actual result: -------------- nothing.