PHP COURSE • LESSON 13
PHP Switch Statement
The switch statement is used when you want to execute different code blocks based on different conditions.
PHP Switch Syntax
switch.php
<?php
$day = 2;
switch($day){
case 1:
echo "Monday";
break;
case 2:
echo "Tuesday";
break;
case 3:
echo "Wednesday";
break;
default:
echo "Unknown Day";
}
?>
Remember
The break keyword stops the switch from continuing to the next case.