一段 PHP 程式碼
PHP 流程控制替代語法:
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
| <?php
for ($i=0;$i<=10;$i++):
echo $i++;
endfor;
for($j=0;$j<=100;$j++) {
echo $j;
}
# =======================
foreach($todo as $item):
echo $item;
endforeach;
foreach($todo as $list){
echo $list;
}
# =======================
if ($username=='boss'):
echo 'goods';
elseif ($username=='joe'):
echo 'soso';
else:
echo 'OMG';
endif;
if ($username=='bill') {
echo 'Happy';
} else if ($username=='mary') {
echo 'Beautiful';
} else {
echo 'So Good';
}
# =======================
while(true):
echo "Luck!";
endwhile;
while($i<=7) {
echo "Week";
}
# =======================
switch($func):
case 'about':
echo 'about page';
break;
case 'dashborad':
echo 'DashBorad Page';
break;
default:
echo 'Login Page';
break;
endswitch;
switch($i) {
case 1:
echo '一';
break;
case 2:
echo '二';
break;
case 3:
echo '三';
break;
default:
echo '零';
break;
}
?>
|
夾在中間能夠正常!