PHP switch case statement
In this tutorial I will show you with code eaxmples how to use the switch - case statement in PHP.
Step 1 - Switch case basics
PHP switch case statement
The switch case statement can be very usefull and makes your code more readable if you need to make a lot of decisions with the if - elseif - else statement. Let's suppose the following example where we use the if-else sollution:
Code:
Code:
This example is not exactly the same as the "if" version as for example in case of $x=10 this code prints nothing. To solve this we can extend our switch statement.
Next Step of PHP switch case statement
Tags: PHP switch case, PHP switch, PHP case, switch case, php, switch, case
| PHP switch case statement - Table of contents |
|---|
| Step 1 - Switch case basics |
| Step 2 - Extend swich with default |