-
-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathswitch.php
More file actions
73 lines (67 loc) · 1.3 KB
/
switch.php
File metadata and controls
73 lines (67 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
switch (2) {
case 1:
$test = 'first';
break;
case 2:
$test = 'second';
break;
case 10:
case 20:
$test = 'big';
break;
case 100:
default:
$test = 1;
}
switch ($var):
case 1:
case 2:
echo "Goodbye!";
break;
default:
echo "I only understand 1 and 2.";
endswitch;
switch ( 2 ) {
case 1:
$test = 'first';
break;
default:
$test = 1;
}
switch ($i):
case 0:
echo "i equals 0";
break;
case 1:
echo "i equals 1";
break;
case 2:
echo "i equals 2";
break;
case 3:
default:
echo "i is not equal to 0, 1 or 2";
endswitch;
switch ($expr) {
case 0:
echo 'First case, with a break';
break;
case 1:
echo 'Second case, which falls through';
// no break
case 2:
case 3:
case 4:
echo 'Third case, return instead of break';
return;
default:
echo 'Default case';
break;
}
switch ($longLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongVariable) {}
switch ($longLongLongLongLongLongLongVariable && $longLongLongLongLongLongLongVariable) {}
switch (1) {
case $exception->veryVeryVeryVeryVeryVeryVeryVeryVeryLongMethod()->veryVeryVeryVeryVeryVeryVeryLongProperty:
break;
}