PHP switch…case…break statements work like an if…elseif…else statements.

A break statement is used to prevent the code from running into the next case automatically.

A default statement is used if no match is found.

Syntax:
switch (n)
{
case value1:
code to be executed if n=value1;
break;
case value2:
code to be executed if n=value2;
break;
case value3:
code to be executed if n=value3;
break;
...
default:
code to be executed if no match is found;
}

Example


<?php
$name="Bryan";
switch ($name)
{
case "Bryan":
  echo "Your name is Bryan";
  break;
case "Petter":
  echo "Your name is Petter";
  break;
case "John":
  echo "Your name is John";
  break;
default:
  echo "Your name is not Bryan, Petter, or John";
}
?>

The above example is similar using if…elseif…else statement below.


<?php
$name="Bryan";

if($name == "Bryan"){
  echo "Your name is Bryan";
}elseif($name == "Petter"){
  echo "Your name is Petter";
}elseif($name == "John"){
  echo "Your name is John";
}else{
  echo "Your name is not Bryan, Petter, or John";
}
?>

How to take Cialis it seems to me that would already be time to cease to discuss this question. As I already answered it not once. Have it in a look. You shouldn’t worry! All deer go south when they are called by homesickness. Are turned and lie on snow till some hours.