Example
Use default to handle unspecified cases in a switch block:
html
<?php
$a = 4;
switch($a) {
case 1: echo "One"; break;
case 2:
echo "Two"; break;
case 3: echo "Three"; break;
default:
echo "Many"; break;
}
?>
Definition and Usage
The default keyword is used in a switch block to specify which code to run when none of the case statements were matched by the expression.
Related Pages
The switch keyword.