2012-10-31 17:46:48 +01:00
|
|
|
switch/case/default
|
|
|
|
-----
|
|
|
|
<?php
|
|
|
|
|
|
|
|
switch ($expr) {
|
|
|
|
case 0:
|
|
|
|
echo 'First case, with a break';
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
echo 'Second case, which falls through';
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
echo 'Third case, return instead of break';
|
|
|
|
return;
|
2018-01-30 23:06:20 +01:00
|
|
|
// Comment
|
2012-10-31 17:46:48 +01:00
|
|
|
default:
|
|
|
|
echo 'Default case';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
-----
|
|
|
|
switch ($expr) {
|
|
|
|
case 0:
|
|
|
|
echo 'First case, with a break';
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
echo 'Second case, which falls through';
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
echo 'Third case, return instead of break';
|
|
|
|
return;
|
2018-01-30 23:06:20 +01:00
|
|
|
// Comment
|
2012-10-31 17:46:48 +01:00
|
|
|
default:
|
|
|
|
echo 'Default case';
|
|
|
|
break;
|
|
|
|
}
|