PHP default Keyword
Example
Use default to handle unspecified cases in a switch block:
<?php
$a = 4;
switch($a) {
case 1: echo "One"; break;
case 2:
echo "Two"; break;
case 3: echo "Three"; break;
default:
echo "Many"; break;
}
?>
Try it Yourself »
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.
Read more about the switch conditional in our PHP switch Statement Tutorial.
❮ PHP Keywords