mirror of
https://github.com/php/php-src.git
synced 2024-10-01 23:06:11 +00:00
de80e3ce4b
foreach only allowed variables to be traversed by reference. This never really made sense because a) Expressions like array(&$a, &$b) can be meaningfully iterated by-ref b) Function calls can return by-ref (so they can also be meaningfully iterated) c) Iterators could at least in theory also be iterated by-ref (not sure if any iterator makes use of this) With by-ref generators the restriction makes even less sense, so I removed it altogether.
19 lines
231 B
PHP
19 lines
231 B
PHP
--TEST--
|
|
Temporary array expressions can be iterated by reference
|
|
--FILE--
|
|
<?php
|
|
|
|
$a = 'a';
|
|
$b = 'b';
|
|
|
|
foreach ([&$a, &$b] as &$value) {
|
|
$value .= '-foo';
|
|
}
|
|
|
|
var_dump($a, $b);
|
|
|
|
?>
|
|
--EXPECT--
|
|
string(5) "a-foo"
|
|
string(5) "b-foo"
|