ID:               36018
 Comment by:       postings-php-bug at hans-spath dot de
 Reported By:      ozone at cname dot com
 Status:           Feedback
 Bug Type:         Documentation problem
 Operating System: linux 2.6.13.2
 PHP Version:      5.1.2
 New Comment:

I can reproduce the error message using the given code.
PHP_VERSION == "5.2.3-0.dotdeb.1"
(on Debian Etch, Kernel 2.6.18-4-686)


Previous Comments:
------------------------------------------------------------------------

[2007-08-20 12:41:47] [EMAIL PROTECTED]

Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

Can you please try it in a new version?

------------------------------------------------------------------------

[2006-01-15 12:12:39] [EMAIL PROTECTED]

The behavior is expected. PHP will only handle super globals correctly
if use their full name. The documentation is wrong on this. (The reason
for this particular behavior is that PHP will only populate the super
globals when they are first used, but PHP can only detect that when
you're using the full name only).

------------------------------------------------------------------------

[2006-01-15 06:38:35] ozone at cname dot com

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.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=36018&edit=1

Reply via email to