How to use Switch case in php

PHP

Switch case is used to catch the proper result coming and then matching it and show the proper output. We can say its faster and smooth coding then that of if condition. If we have many conditions then switch case is used. If you have one variable and its value can be 1 or 2 or 3 or 4 or…….. then you can use the switch case so you can set many conditions for all the cases.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SWITCH CASE Example in PHP</title>
</head>
<body>
<?php
$case="A";
switch ($case)
{
case "A":
echo "If $case = A then it wil go here!";
break;
case "B":
echo "If $case = B then it wil go here!";
break;
case "C":
echo "If $case = C then it wil go here!";
break;
default:
echo "If $case is&nbsp; not A or B or C then it wil go here!";
}
// Lets take one example if you will get random number in a variable so you can use switch case there

$case=1;
switch ($case)
{
case 1:
echo "1";
break;
case 2:
echo "2";
break;
case 3:
echo "3";
break;
default:
echo "0";
}

?>
</body>
</html>
-->