Req #42415 [Opn->Wfx]: Key element cannot be a reference
| From: | nikic@php.net | Date: | Wed, 31 Dec 2014 16:28:41 +0000 |
| Subject: | Req #42415 [Opn->Wfx]: Key element cannot be a reference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189565@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=42415&edit=1
ID: 42415
Updated by: nikic@php.net
Reported by: romaneos at gmail dot com
Summary: Key element cannot be a reference
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: Windows
PHP Version: 5CVS-2007-08-24 (CVS)
Block user comment: N
Private report: N
New Comment:
Marking as Wfx as this feature request is simply not feasible from a technical point of view.
Previous Comments:
------------------------------------------------------------------------
[2007-08-26 23:21:41] judas dot iscariote at gmail dot com
This is the expected behaviuor. the engine is just warning you that you are writting bad code.
------------------------------------------------------------------------
[2007-08-24 13:54:11] romaneos at gmail dot com
Description:
------------
Fatal error: Key element cannot be a reference
Reproduce code:
---------------
foreach($list as &$key=>&$value) {
$key = $key+1;
$value = $value+1;
}
This code will generate error:
Fatal error: Key element cannot be a reference
Expected result:
----------------
$list = array(1 => 2, 5 => 6);
foreach($list as &$key=>&$value) {
$key = $key+1;
$value = $value+1;
}
Expected result:
$list == array (
2 => 3,
6 => 7
)
Actual result:
--------------
Fatal error: Key element cannot be a reference
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=42415&edit=1