PHP Switch Statement

Switch Statement is the same as If…Else Statements except that it is easier to use if you have multiple conditions.
Switch Syntax switch (condition) { case condition1: statement to be executed if n=condition1; break; case condition 2: statement to be executed if n=condition2; break; default: statement to be executed if n is different from both condition 1 and condition 2; } condition is a variable expression that is evaluated once. If the first condition is true then the succeeding condition will not be executed anymore, else it will continue until it finds the condition that is equals to true or execute the default statement if no matching condition.
Example

Add new comment