PHP switch case Statement - Mostlikers

28 July, 2014

PHP switch case Statement

Php value compare to multi value in the sense we use if else statement method that time we use lot of value comparison method  in if else statement method. 10 or 20 value comparison statement execute time take delay, that case use switch statement this multiple value check time and comparison method also very easy.



Syntax

switch () {

  case 0;
  echo "your message"
  break;

  case 2;
  echo "your message"
  break;

 }
  

Sample code



<?php
$favortcolor="blue";
switch ($favortcolor) {

  case "blue";
  echo "Sharper";
  break;

  case "blue";
  echo "Sharper"
  break;
  
  case "black";
  echo "looser"
  break;
 }
?>

No comments:

Post a Comment