switch.test 656 B

1234567891011121314151617181920212223242526272829303132333435
  1. switch/case/default
  2. -----
  3. <?php
  4. switch ($expr) {
  5. case 0:
  6. echo 'First case, with a break';
  7. break;
  8. case 1:
  9. echo 'Second case, which falls through';
  10. case 2:
  11. case 3:
  12. case 4:
  13. echo 'Third case, return instead of break';
  14. return;
  15. default:
  16. echo 'Default case';
  17. break;
  18. }
  19. -----
  20. switch ($expr) {
  21. case 0:
  22. echo 'First case, with a break';
  23. break;
  24. case 1:
  25. echo 'Second case, which falls through';
  26. case 2:
  27. case 3:
  28. case 4:
  29. echo 'Third case, return instead of break';
  30. return;
  31. default:
  32. echo 'Default case';
  33. break;
  34. }