#30935 [Opn]: compact fails for superglobals
| From: | bugs-php-net at schirmeier dot com | Date: | Mon, 29 Nov 2004 21:40:06 +0000 |
| Subject: | #30935 [Opn]: compact fails for superglobals | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-69624@lists.php.net to get a copy of this message | ||
ID: 30935
User updated by: bugs-php-net at schirmeier dot com
Reported By: bugs-php-net at schirmeier dot com
Status: Open
Bug Type: Arrays related
Operating System: Linux x86
PHP Version: 5.0.2
New Comment:
Well, Keita Ito thankfully informed me about the "Warning: Please note
that variable variables cannot be used with PHP's Superglobal arrays
within functions or class methods." on
http://www.php.net/variables.variable -- which
also seems to be valid
for compact().
It'd be helpful if this could be included in the documentation for
compact().
Or even better: Remove this weird behaviour for variable variables AND
compact().
Previous Comments:
------------------------------------------------------------------------
[2004-11-29 22:22:48] bugs-php-net at schirmeier dot com
"Version:" corrected to latest "stable" version the bug was reproduced
with.
------------------------------------------------------------------------
[2004-11-29 22:19:05] bugs-php-net at schirmeier dot com
Description:
------------
compact() does not "see" superglobals like $_GET/$_POST/etc. when
called within a function (documentation says: "Any strings that are not
set will simply be skipped.").
Tested on PHP versions 4.3.2, 4.3.9 (both Apache module and cli),
5.0.0, 5.0.1 (cli), 5.0.2, php5.1-dev-cli.
Reproduce code:
---------------
<?php
function foo()
{
var_dump(compact('_GET', '_POST', '_SESSION', '_ENV',
'_COOKIE',
'_SERVER'));
}
var_dump(compact('_GET', '_POST', '_SESSION', '_ENV',
'_COOKIE',
'_SERVER'));
echo "\n------------------------\n";
foo();
?>
Expected result:
----------------
A dump of an array with indexes '_GET', '_POST' etc. pointing to the
contents of the respective superglobals, then a dashed line, then the
same dump again.
Actual result:
--------------
The expected dump, the dashed line, and a:0:{}.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30935&edit=1