PHP case Keyword

P
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

Tutor Network

Share this

Learn PHP from A to Z