PHP Switch statement


Switch statement is a control statement that allows us to choose only one choice among the many given choices. it is a control statement used to make a selection between many alternatives.
Syntax:-
  switch(choice)
 {
    case value 1:
    Block -1;
    break;
   case value 2:
    Block – n;
    break ;
    default:
    Block - d
 }

W.A.P to design a calculator using switch

 <html>
 <body>
  <?php
   $ch=3;
   switch($ch)
  {
   case 1:
   echo “one”;
   break;
   case 2:
   echo “Two”;
   break;
   case 3:
   echo “Three”;
   break;
   default:
   echo “ only 1 to 3”;
  }
  ?>
 </body>
 </html>

Output

    3
Three