php

Switch case in PHP

<?php
    $type = "2";
    switch($type) {
        case "1":
            echo "case 1";
            break;
        case "2":
            echo "case 2";
            break;
        default:
            break;
    }
?>
Output
case 2

The switch can be used to perform different actions and execute code blocks based on different conditions. 

Was this helpful?