Req #62132 [Opn->Dup]: Do not keep last element treated by foreach referenced
| From: | cataphract@php.net | Date: | Thu, 24 May 2012 11:25:24 +0000 |
| Subject: | Req #62132 [Opn->Dup]: Do not keep last element treated by foreach referenced | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-170770@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62132&edit=1
ID: 62132
Updated by: cataphract@php.net
Reported by: chealer at gmail dot com
Summary: Do not keep last element treated by foreach
referenced
-Status: Open
+Status: Duplicate
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: 5.4.3
Block user comment: N
Private report: N
New Comment:
The proper venue for this discussion is the internals mailing list.
Previous Comments:
------------------------------------------------------------------------
[2012-05-24 01:46:12] laruence@php.net
this is more about a wrong usage, fix this will introduce a big bc break.
------------------------------------------------------------------------
[2012-05-24 01:04:00] chealer at gmail dot com
Description:
------------
As explained on http://ca.php.net/manual/en/control-structures.foreach.php
:
Warning
Reference of a $value and the last array element remain even after the foreach loop. It is
recommended to destroy it by unset().
In my opinion, PHP shouldn't keep the last element referenced by default, but at least, please
provide a syntax which will not keep it. The current situation causes bugs like:
https://bugs.php.net/bug.php?id=29992
https://bugs.php.net/bug.php?id=40654
https://bugs.php.net/bug.php?id=47388
https://bugs.php.net/bug.php?id=49386
https://bugs.php.net/bug.php?id=50485
https://bugs.php.net/bug.php?id=54189
aharvey@php.net pointed out that this problem was already discussed (see https://bugs.php.net/bug.php?id=60024 ).
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62132&edit=1