PHP case Keyword

PHP break Keyword
PHP as Keyword

In this article, you will learn how to use case keyword in PHP. The case keyword in PHP is used to jump to a line of code when an expression has a specific value in a switch conditional.

examples of the CASE keyword

Example 1. In this example, we use case to run some code when a variable has a specified value.

<?php
$a = 3;
switch($a) {
  case 1:
    echo "One";
    break;
  case 2:
    echo "Two";
    break;
  case 3:
    echo "Three";
    break;
}
?>
PHP break Keyword
PHP as Keyword
en English
X
Scroll to Top