xref: /PHP-7.0/tests/lang/foreachLoop.011.phpt (revision 97fe15db)
1--TEST--
2Changing from an interable type to a non iterable type during the iteration
3--FILE--
4<?php
5echo "\nChange from array to non iterable:\n";
6$a = array(1,2,3);
7$b=&$a;
8foreach ($a as $v) {
9	var_dump($v);
10	$b=1;
11}
12
13echo "\nChange from object to non iterable:\n";
14$a = new stdClass;
15$a->a=1;
16$a->b=2;
17$b=&$a;
18foreach ($a as $v) {
19	var_dump($v);
20	$b='x';
21}
22
23?>
24--EXPECTF--
25
26Change from array to non iterable:
27int(1)
28int(2)
29int(3)
30
31Change from object to non iterable:
32int(1)
33int(2)
34