Download src/php/php-src/Zend/tests/foreach/bug67633.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 544 Bytes
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/foreach/bug67633.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/Zend/tests/foreach/bug67633.phpt
-
curl -L -o bug67633.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/foreach/bug67633.phpt
544 Bytes
| --TEST-- | |
| Bug #67633: A foreach on an array returned from a function not doing copy-on-write | |
| --FILE-- | |
| 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" | |
| } | |