#27923 [Opn->Fbk]: foreach() with references broken when iterating only over value
| From: | sniper@php.net | Date: | Mon, 12 Apr 2004 23:31:58 +0000 |
| Subject: | #27923 [Opn->Fbk]: foreach() with references broken when iterating only over value | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-57990@lists.php.net to get a copy of this message | ||
ID: 27923
Updated by: sniper@php.net
Reported By: adam at trachtenberg dot com
-Status: Open
+Status: Feedback
Bug Type: Zend Engine 2 problem
Operating System: *
PHP Version: 5CVS-2004-04-08 (dev)
New Comment:
your example doesn't have any references in it..? (and it works fine
when I replace the last ) with } :)
Previous Comments:
------------------------------------------------------------------------
[2004-04-08 15:20:44] adam at trachtenberg dot com
Description:
------------
In PHP 5, foreach() allows you to iterate over values by
reference. This does not work when you do foreach($array
as $value) instead of foreach($array as $key => $value).
I believe this patch fixes the problem, but someone
should *really* double check it. :)
http://www.trachtenberg.com/patches/
foreach_by_reference.txt
Reproduce code:
---------------
php -r '$array = array(); foreach($array as $value) {)'
Expected result:
----------------
Nothing.
Actual result:
--------------
PHP Fatal error: Key element cannot be a reference in
Command line code on line 1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27923&edit=1