Saturday, 25 August 2012

PHP switch statement

PHP switch statement is a better alternative than a large series of if-else-if statements. It can switch in different part of the code based on condition. Here is the general form of a PHP switch statement. 
case value1
executed statement;
case value2
executed statement;
// default statement

In the PHP switch statement duplicate case values are not allowed. The expression value checks every case iteratively if a match is found then the following case statement is executed. If none of the cases does not matches the value of the expression, then the default statement is executed.

No comments:

Post a Comment