1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/Zend/tests/foreach/bug67633.phpt
DanielEScherzer bce1f4aeb1 Zend/tests: organize some tests with sub directories (3) (#16444)
First pass at moving `Zend/tests/bug*` tests to existing sub directories

Work towards GH-15631
2025-02-10 00:35:51 +00:00

45 lines
544 B
PHP

--TEST--
Bug #67633: A foreach on an array returned from a function not doing copy-on-write
--FILE--
<?php
function id($x) {
return $x;
}
function &ref_id(&$x) {
return $x;
}
$c = 'c';
$array = ['a', 'b', $c];
foreach(id($array) as &$v) {
$v .= 'q';
}
var_dump($array);
foreach(ref_id($array) as &$v) {
$v .= 'q';
}
var_dump($array);
?>
--EXPECT--
array(3) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "c"
}
array(3) {
[0]=>
string(2) "aq"
[1]=>
string(2) "bq"
[2]=>
&string(2) "cq"
}