In this tutorial you will learn about the PHP Switch Statement and its application with practical example.
The Switch Statement
The switch statement is simplified form of the nested if … else if statement , it avoids long blocks of if..elseif..else code.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
switch (expression) { case val1: //Block of code to be executed if expression = val1; break; case val2: //Block of code to be executed if expression = val2; break; default: //Block of code to be executed //if expression is different //from both val1 and val2; } |