The PHP switch Case statement is followed by the variable or value to compare
The case statements inside the switch block are followed by the alternate variable or value to compare
The Code following the colon in the case statement will only execute if the switch and case values match
Only one dereliction case is allowed, which will execute if no break statement exists previous
a,The break statement prevents any following cases from being tested, therefore precluding their law from running
b, The continue statement can be used in place of break
continue accepts an voluntary numeric argument which tells it how numerous situations of enclosing circles it should skip – see latterly in the composition for what this means in switch statements
Switch/ case makes a loose comparison by dereliction
This means that 2 and “ 2” are equal – as are 0 and FALSE – as the variable type is ignored
See latterly in the composition on how to use strict comparisons where the variable type are considered
<?php
$i=250;
Switch($i)
{
Case 150:
echo "Value is 150";
Break;
Case 250:
echo "Value is 250";
Break;
Case 350:
echo "Value is 350";
Break;
Case 450:
echo "Value is 450";
Break;
Default:
echo "Enter Correct Value";
Break;
}
?>
Learn also PHP Variables Tutorials for Beginners because wihthout good knowledge on basic variables you don't understand PHP Switch Case by CodeExampler Website
Top comments (1)
How to Comment in Javascript by CodeExampler for Free