switch statements

switch statements is used where you want to execute one block of code out of many.

Syntax

switch (value)
{
case value1:
code to be executed if value = value1;
break;
case value2:
code to be executed if value = value2;
break;
default:
code to be executed
if value is different
from both value1 and value2;
}

Example of switch

$a=10;
switch ($a)
{
case 10:
code to be executed if $a=10;
break;
case 20:
code to be executed if $a=20;
break;
default:
code to be executed
if value is different
from both value1 and value2;
}