PHP endswitch Keyword

PHP extends Keyword
PHP endforeach Keyword

In this article, you will learn how to end the switch block in PHP. The endswitch keyword in PHP is used to mark the end of a switch conditional which was started with the switch(…): syntax.

examples of the ENDSWITCH keyword

Example 1. In this example, we close a switch conditional 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;
endswitch;
?>
PHP extends Keyword
PHP endforeach Keyword

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top