1234567891011121314151617181920212223242526272829303132333435 |
- 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;
- 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;
- default:
- echo 'Default case';
- break;
- }
|