The Switch Statement
If you want to select one of many blocks of code to be executed, use the Switch statement.
http://www.phpsu.com
The switch statement is used to avoid long blocks of if..elseif..else code.
phpsu.com is a free phpscool
Syntax
switch (expression) |
Example
This is how it works: welcome to phpsu.com
- A single expression (most often a variable) is evaluated once
- The value of the expression is compared with the values for each case in the structure
- If there is a match, the code associated with that case is executed
- After a code is executed, break is used to stop the code from running into the next case
- The default statement is used if none of the cases are true
<html> <?php </body> |
TITLE:PHP Switch Statement