PHP default Keyword

PHP do Keyword
PHP declare Keyword

In this article, you will learn how to use default keyword in PHP. The default keyword in PHP is used in a switch block to specify which code to run when none of the case statements were matched by the expression.

examples of the DEFAULT keyword

Example 1. In this example, we 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;
}
?>
PHP do Keyword
PHP declare Keyword
en English
X
Scroll to Top