#39011 [Bgs->Opn]: foreach($_GET as $key => &$value) causes later bugs passing $_GET as a paramete
| From: | php_bug dot email at email dot digiways dot com | Date: | Sun, 01 Oct 2006 21:00:12 +0000 |
| Subject: | #39011 [Bgs->Opn]: foreach($_GET as $key => &$value) causes later bugs passing $_GET as a paramete | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-102948@lists.php.net to get a copy of this message | ||
ID: 39011
User updated by: php_bug dot email at email dot digiways dot com
Reported By: php_bug dot email at email dot digiways dot com
-Status: Bogus
+Status: Open
Bug Type: Arrays related
Operating System: Windows XP
PHP Version: 5.1.6
New Comment:
Where exactly is this behaviour documented? Can you point to the
documentation page as I failed to find this.
Also, another defect http://bugs.php.net/bug.php?id=29992 which was
referenced here is a different problem. In my case I do not reuse the
reference variable $value .
Previous Comments:
------------------------------------------------------------------------
[2006-10-01 20:39:17] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
bogus
------------------------------------------------------------------------
[2006-10-01 20:24:34] judas dot iscariote at gmail dot com
this is the expected behaviuor, and not a bug. :P
the reasons are clearly explained by gardan at gmx dot de on this
report, please do a search before reporting
http://bugs.php.net/bug.php?id=29992
------------------------------------------------------------------------
[2006-10-01 20:13:53] sitnikov at infonet dot ee
confirmed with PHP Version 5.2.0RC5-dev
------------------------------------------------------------------------
[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