/hphp/test/slow/array_for_each/variable-variable-foreach.php
PHP | 39 lines | 23 code | 11 blank | 5 comment | 0 complexity | 781396577e8b705778c03de3d2365677 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
- <?hh
- ArrayForEachVariableVariableForeach::$rows=varray[1,2,3];
- function fn1() {
- $a="rows";
- $b="row";
- // TYPICAL FOREACH
- foreach(ArrayForEachVariableVariableForeach::$rows as ArrayForEachVariableVariableForeach::$row) {
- fn2();
- }
- // THE MALFORMED ARRAY
- foreach(ArrayForEachVariableVariableForeach::$rows as ArrayForEachVariableVariableForeach::$row) {
- fn2();
- }
- }
- function fn2() {
- $row = ArrayForEachVariableVariableForeach::$row;
- echo "row={$row}\n";
- }
- // ORIGINAL ARRAY
- print_r(ArrayForEachVariableVariableForeach::$rows);
- // SOME ITERATIONS
- fn1();
- // THE MALFORMED ARRAY
- print_r(ArrayForEachVariableVariableForeach::$rows);
- abstract final class ArrayForEachVariableVariableForeach {
- public static $rows;
- public static $row;
- }