Home of web learners

www.webn3rd.com

Switch is used to execute code when your value and the value in the condition matched.

Lets look an example:

<?php
$input=2;
Switch($input){
case 1:
echo "your input value is one";
break;
case 2:
echo "your input value is two";
break;
default:
echo "your input value doesnt match";
}
?>

output:

your input value is two

here,you see that your input variable data try to match with value in case,if the value in case matched with your variable data,then the line after case is going to execute and when break found after executing,then it come out from switch

If any value not matched with case with your input data,then default case works

webn3rd.com

About webn3rd