The switch statement executes one line at a line (actually a statement-taking statement), and here's how multiple values for PHP switch statements match the same code block
Let's talk about the format of the switch () statement switch (expression) { case matching 1: when matching 1 and expression matches successfully executed code; break; Case matching 2: when matching 2 and expressions match successfully executed code; break; default: If the statement does not have the code executed with the expression success; understanding How the switch is performed is very important. The switch statement executes one line at a line (actually a statement-taking statement). No code is executed at the beginning. PHP begins executing a statement only if the value in one case statement matches the value of the switch expression until the switch's program segment ends or the first break statement is encountered. If you do not write a break at the end of the statement section of the case, PHP will continue to execute the statement section in the next box. Example: code as follows: <?php switch ($i) { case 1: echo "$i value is 1"; break; cases 2:&nbs P The value of Echo $i is 2 "; break; case 3: echo" $i value is 3 "; break; default: echo" $i value is not 1, 2, 3 "; & nbsp } ?> The statement in a case can also be empty, so that only the control is transferred to the next box of statements, know that the next case of the statement block is not empty, so that a number of values to match the consent code block: when $ The value of I is 1 or 2 or 3 o'clock the output of the same statement: code is as follows: <?php switch ($i) { case 1: Case 2: case 3: echo "$i value The value for $i is 1 or 2 or 3 "; break; } ?>