I noticed you can indeed use the continue
keyword in a switch statement, but on PHP it doesn't do what I expected.
If it fails with PHP, who knows how many other languages it fails too? If I switch between languages a lot, this can be a problem if the code doesn't behave like I expect it to behave.
Should I just avoid using continue
in a switch statement then?
PHP (5.2.17) fails:
for($p = 0; $p < 8; $p++){
switch($p){
case 5:
print"($p)";
continue;
print"*"; // just for testing...
break;
case 6:
print"($p)";
continue;
print"*";
break;
}
print"$p\r\n";
}
/*
Output:
0
1
2
3
4
(5)5
(6)6
7
*/
C++ seems to work as expected (jumps to end of for loop):
for(int p = 0; p < 8; p++){
switch(p){
case 5:
cout << "(" << p << ")";
continue;
cout << "*"; // just for testing...
break;
case 6:
cout << "(" << p << ")";
continue;
cout << "*";
break;
}
cout << p << "\r\n";
}
/*
Output:
0
1
2
3
4
(5)(6)7
*/