Example
Use case to run some code when a variable has a specified value:
html
<?php
$a = 3;
switch($a) {
case 1:
echo "One";
break;
case 2:
echo "Two";
break;
case 3:
echo "Three";
break;
}
?>
Definition and Usage
The case keyword is used to jump to a line of code when an expression has a specific value in a switch conditional.
Related Pages
The switch keyword.