From:             bugs-php-net at schirmeier dot com
Operating system: Linux x86
PHP version:      4.3.9
PHP Bug Type:     Arrays related
Bug description:  compact fails for superglobals

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 bug report at http://bugs.php.net/?id=30935&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30935&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=30935&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=30935&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30935&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30935&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30935&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30935&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30935&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30935&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30935&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=30935&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=30935&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30935&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30935&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30935&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30935&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30935&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30935&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30935&r=mysqlcfg

Reply via email to