1$age=20;
2switch ($age) {
3 case 19:
4 echo "Age is 18";
5 break;
6 case 20:
7 echo "Age is 20";
8 break;
9 case 21:
10 echo "Age is 21";
11 break;
12}
1switch ($element) {
2 case 0:
3 echo "i es igual a 0";
4 break;
5 case 1:
6 echo "i es igual a 1";
7 break;
8 case 2:
9 echo "i es igual a 2";
10 break;
11}
1
2<?php
3switch ($i) {
4 case "apple":
5 echo "i is apple";
6 break;
7 case "bar":
8 echo "i is bar";
9 break;
10 case "cake":
11 echo "i is cake";
12 break;
13}
14?>
15
16
1switch ($i) {
2 case 0:
3 echo "i ist gleich 0";
4 break;
5 case 1:
6 echo "i ist gleich 1";
7 break;
8 case 2:
9 echo "i ist gleich 2";
10 break;
11}
1switch ($i) {
2 case 0:
3 echo "i equals 0";
4 break;
5 case 1:
6 echo "i equals 1";
7 break;
8 case 2:
9 echo "i equals 2";
10 break;
11 default:
12 echo "i is not equal to 0, 1 or 2";
13}
1<?php
2if ($i == 0) {
3 echo "i equals 0";
4} elseif ($i == 1) {
5 echo "i equals 1";
6} elseif ($i == 2) {
7 echo "i equals 2";
8}
9
10switch ($i) {
11 case 0:
12 echo "i equals 0";
13 break;
14 case 1:
15 echo "i equals 1";
16 break;
17 case 2:
18 echo "i equals 2";
19 break;
20}
21?>