xref: /PHP-5.3/tests/lang/foreachLoop.003.phpt (revision 176012df)
1--TEST--
2Foreach loop tests - error case: not an array.
3--FILE--
4<?php
5echo "\nNot an array.\n";
6$a = TRUE;
7foreach ($a as $v) {
8	var_dump($v);
9}
10
11$a = null;
12foreach ($a as $v) {
13	var_dump($v);
14}
15
16$a = 1;
17foreach ($a as $v) {
18	var_dump($v);
19}
20
21$a = 1.5;
22foreach ($a as $v) {
23	var_dump($v);
24}
25
26$a = "hello";
27foreach ($a as $v) {
28	var_dump($v);
29}
30
31echo "done.\n";
32?>
33--EXPECTF--
34
35Not an array.
36
37Warning: Invalid argument supplied for foreach() in %s on line 4
38
39Warning: Invalid argument supplied for foreach() in %s on line 9
40
41Warning: Invalid argument supplied for foreach() in %s on line 14
42
43Warning: Invalid argument supplied for foreach() in %s on line 19
44
45Warning: Invalid argument supplied for foreach() in %s on line 24
46done.
47