Req #60024 [Dup]: Do not keep last element treated by foreach referenced
| From: | chealer at gmail dot com | Date: | Tue, 07 Feb 2012 02:38:24 +0000 |
| Subject: | Req #60024 [Dup]: Do not keep last element treated by foreach referenced | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-167236@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60024&edit=1
ID: 60024
User updated by: chealer at gmail dot com
Reported by: chealer at gmail dot com
Summary: Do not keep last element treated by foreach
referenced
Status: Duplicate
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
Thank you. I read the discussion once, but I didn't see where it rejects this. Could the
rejections be quoted or pointed more specifically?
Previous Comments:
------------------------------------------------------------------------
[2012-02-07 00:10:38] aharvey@php.net
Sure, it's come up on the mailing list a few times, but the one I was thinking of
specifically is: http://comments.gmane.org/gmane.comp.php.devel/59471
------------------------------------------------------------------------
[2012-02-06 22:24:17] chealer at gmail dot com
Could the discussion be linked to?
This is not a duplicate of any of the reports indicated. The reports indicated are reports of
application bugs as PHP bugs, which are therefore invalid. This report is asking to change PHP, in
order to avoid such application bugs.
------------------------------------------------------------------------
[2012-02-06 00:53:13] aharvey@php.net
This has previously been discussed and rejected, due to users relying both on
PHP's lack of block scope and foreach's by-reference syntax. (Sometimes both at
once, unfortunately.)
Duplicate of bug #29992, bug #47388, bug #54189, bug #50485, and probably a bunch
of others.
------------------------------------------------------------------------
[2012-02-06 00:47:50] DeveloperGuy2008 at yahoo dot com
Please fix this. It creates a lot of hard to debug bugs.
------------------------------------------------------------------------
[2011-10-09 21:09:19] 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 situations causes bugs like https://bugs.php.net/bug.php?id=49386
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60024&edit=1