default
The default statement is used if no match is found.
$x=5;
switch ($x) {
case 1:
echo "One";
break;
case 2:
echo "Two";
break;
default:
echo "No match";
}
//Outputs "No match"
switch ($x) {
case 1:
echo "One";
break;
case 2:
echo "Two";
break;
default:
echo "No match";
}
//Outputs "No match"
The default statement is optional, so it can be omitted.
No comments:
Post a Comment