xref: /PHP-7.1/tests/lang/020.phpt (revision 7af945e2)
1--TEST--
2Switch test 1
3--FILE--
4<?php
5
6$i="abc";
7
8for ($j=0; $j<10; $j++) {
9switch (1) {
10  case 1:
11  	echo "In branch 1\n";
12  	switch ($i) {
13  		case "ab":
14  			echo "This doesn't work... :(\n";
15  			break;
16  		case "abcd":
17  			echo "This works!\n";
18  			break;
19  		case "blah":
20  			echo "Hmmm, no worki\n";
21  			break;
22  		default:
23  			echo "Inner default...\n";
24  	}
25  	for ($blah=0; $blah<200; $blah++) {
26  	  if ($blah==100) {
27  	    echo "blah=$blah\n";
28  	  }
29  	}
30  	break;
31  case 2:
32  	echo "In branch 2\n";
33  	break;
34  case $i:
35  	echo "In branch \$i\n";
36  	break;
37  case 4:
38  	echo "In branch 4\n";
39  	break;
40  default:
41  	echo "Hi, I'm default\n";
42  	break;
43 }
44}
45?>
46--EXPECT--
47In branch 1
48Inner default...
49blah=100
50In branch 1
51Inner default...
52blah=100
53In branch 1
54Inner default...
55blah=100
56In branch 1
57Inner default...
58blah=100
59In branch 1
60Inner default...
61blah=100
62In branch 1
63Inner default...
64blah=100
65In branch 1
66Inner default...
67blah=100
68In branch 1
69Inner default...
70blah=100
71In branch 1
72Inner default...
73blah=100
74In branch 1
75Inner default...
76blah=100
77