xref: /PHP-5.4/tests/lang/foreachLoop.011.phpt (revision 176012df)
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)
28
29Warning: Invalid argument supplied for foreach() in %s on line 5
30
31Change from object to non iterable:
32int(1)
33
34Warning: Invalid argument supplied for foreach() in %s on line 15