Source Code:
(back to article)
<?php // Example 1 $dayOfWeek = "Wednesday"; switch ($dayOfWeek) { case "Monday": case "Tuesday": case "Wednesday": case "Thursday": case "Friday": echo "It's a weekday."; break; case "Saturday": case "Sunday": echo "It's a weekend."; break; } // Example 2 $grade = "B"; switch ($grade) { case "A": echo "Excellent!"; break; case "B": echo "Good job!"; break; case "C": echo "Could do better."; break; default: echo "Please enter a valid grade."; }
Result:
Report an issue