Tuesday, 16 August 2016

PHP Basics : Switch case

Hi guyz

Lets see about switch case statements in php, Its just simple





Lets begin your code


<?php
$command = "4";

switch ($command) {
    case "1":
        echo "You chose number 1";
        break;
    case "2":
        echo "You chose number 2";
        break;
    case "3":
        echo "You chose number 3";
        break;
    default:
        echo "You chose out of circle";
}



In this above program, if you declare
 [1] $command=1, it will echo case 1 ,

 [2] $command=2, it will echo case 2,

 [3] $command=3, it will echo case 3,

 [4] if you declare $command other than 1 2 or 3 it will echo default


Its so simple, You can practice and have fun...!


Its cool right ?

No comments:

Post a Comment