ID: 39011
Comment by: sitnikov at infonet dot ee
Reported By: php_bug dot email at email dot digiways dot com
Status: Open
Bug Type: Arrays related
Operating System: Windows XP
PHP Version: 5.1.6
New Comment:
confirmed with PHP Version 5.2.0RC5-dev
Previous Comments:
------------------------------------------------------------------------
[2006-10-01 19:25:34] php_bug dot email at email dot digiways dot com
Description:
------------
if we iterate over $_GET using references (see the example) and pass
$_GET to a function, function modifies $_GET and not the local copy.
For example, save the example code in test.php and open
test.php?mykey=foo
.
Reproduce code:
---------------
<?php
function doit($http_get_params)
{
$http_get_params['mykey'] = 'bar';
echo '<br/>'.$_GET['mykey'];
}
foreach($_GET as $key => &$value) {}
echo '<br/>'.$_GET['mykey'];
doit($_GET);
echo '<br/>'.$_GET['mykey'];
?>
Expected result:
----------------
When we open test.php?mykey=foo I expect to see
foo
foo
foo
Actual result:
--------------
When we open test.php?mykey=foo we actually see
foo
bar
bar
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39011&edit=1