How to use a switch case ‘or’ in PHP?

Prem Tiwari - - PHP Documentation


Problem: How to use a switch case ‘or’ in PHP?
Solution: This can be achieved in 2 ways.

PHP Switch case syntax

Use the switch statement to select one of many blocks of code to be executed.

Method 1: Without using break keyword in one of the switch case.
Example:

Output:

The option is either 1 or 2.

Output:

The option is either 1 or 2

Reference: http://php.net/manual/en/control-structures.switch.php


About: Prem Tiwari

Prem Tiwari is the founder of FreeWebMentor.com and also a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.