The following is a detailed description of the Switch statement in php. When you need to selectively execute one of several code blocks, consider using the Switch statement. Use a Switch statement to avoid lengthy if..elseif..else blocks. How it works:
Example 2 , switch to achieve multiple uses of one page. First, create the test.php page:
Copy code
Note: here sunec omits most of the other code and just writes some of the submit buttons. No matter which button is clicked, it will jump to the solution.php page. The only difference is that the content of the action after the question mark is divided into 4 types. Call it a reminder. Then, create the solution.php page to handle these four operations.
Code description: After receiving the value of action, use the switch statement to assign corresponding operations to it according to the different action values. It's much better than using if else statement. Let’s introduce these, examples of PHP switch statements, I hope it will be helpful to friends who are learning PHP. |