PHP Switch Statement
The switch statement in PHP is used to perform one of several different actions based on several different conditions.
Switch statement
If you want to select a lot of blocks the code will be executed using the switch to speak.
Switch statements are used to avoid long blocks, if ... The ElseIf. Someone else's code.
Grammar
switch (expression)
{
Case Label1:
Code to is executed if expression = Label1;
Break
Case LABEL2:
Code to is executed if expression = Label2;
Break
Default
Code to IS executed
If expression is different
From both Label1 and Label2;
}
For example
How this works:
A single expression (the most common one variable) is the evaluation of the value of
at a time compared to the values expressed in the structure of each case
If there is a match, the code with the execution of the case
after code execution, breaking is used to block the code from running to the next case
The preset statement is true if not used in the case of
pre><?php switch ($x) {case 1:echo "number 1"; Break Case 2:echo "Number 2"; Break Case 3:echo "Number 3"; Break Default:echo "No number between 1 and 3";
</body>