e88eb2a4f9a5680585dfd9a208d2b818 (1)

Published on Slideshow
Static slideshow
Download PDF version
Download PDF version
Embed video
Share video
Ask about this video

Scene 1 (0s)

SWITCH CASE.

Scene 2 (6s)

Presented by L.Chitra.

Scene 3 (12s)

Introduction In PHP,a Switch statement is used to perform different actions based on the value of a given expression. It's a way to simplify a series of if-elseif-else statements when you need to make decisions based on a single value..

Scene 4 (26s)

Syntax Switch (expression) { case valuel: break; case value2: break; default:.

Scene 5 (33s)

Here how it works: 1. 2. 3. 4. 6. The switch keyword initiates the switch statement. The expression you want to evaluate is placed within the parentheses after the switch keyword. The case keyword is followed by a value that you want to compare with the expressron. If the expression matches a case value, the code inside that case block is executed. You can have multiple case blocks. The break statement is used to exit the switch statement after a case is executed. If you omit it, the execution will continue to the next case, which might not be what you want. You can also use a default case, which is executed if none of the case values match the expression..

Scene 6 (1m 5s)

Example Sday = "Wednesday" switch (Sday) { case "Monday": echo "It's the start of the workweek."; break; case "Wednesday": echo "It's hump day!"• break; default: echo "It's some other day."; In this example, since the value of Sday is "Wednesday," it will execute the code in the second case block, and you'll see "It's hump day!" printed..

Scene 7 (1m 23s)

Thank you.