PHP – switch Statement

“switch statement” is one of the best for program execution based on several conditions.

Syntax of “switch statement” in PHP


The “switch statement” will be used mainly to avoid the long tail of “if..elseif..else” statements. It will execute the program based on the parameter to passed “switch statement”. The passed parameter will be check with all the cases and if match found it will execute the program otherwise it will returns to the default statement. We use “break;” to stop the program to check other cases and we can speed up the program execution.

“switch statement” example


Leave a Reply

Your email address will not be published.