PHP switch

Last Updated: February 4, 2022

You can write the several if conditions using the switch statement.

When you have the single condition to check you can use the if..else statement

This is a good practical example for switch statement

switch ($_GET['action']) {
        case "add_service":
            ck_get_template('service/create.php');
            break;
        case "edit_service":
            ck_get_template('service/edit.php');
            break;
        default:
            ck_get_template('service/index.php');

    }
Test