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. 
 
switch(expression){
case value1
executed statement;
break;
case value2
executed statement;
break;
………………
default:
// 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.

Comments

Popular posts from this blog

How to construct a B+ tree with example

How to show only month and year fields in android Date-picker?

Visitor Counter Script Using PHP