Switch Case in PHP

Prem Tiwari - - PHP Tutorials


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.