Switch Case in PHP

By Prem Tiwari in PHP Tutorials. Updated on


This is a basic PHP program to describe the switch case with an example and real-time output.

Below examples will help you in the better understanding of Switch case in PHP programming language. Switch case statement works like the if-else-if statement in PHP programming language.

Switch case in PHP with an example

Below is the standard syntax of switch case statement in PHP programming language.

PHP Switch Case Example

In the below program, I am going to share a PHP program to print the day name based on the entered day number. Copy the below code and execute it with the help of PHP compiler.

Program Out

#First try
Today is Tuesday
#Second try to check default case change the $num values as 8
You have entered a wrong number. Please enter a mumber between 1-7.

Sharing is caring!


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.

You might also like:

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.