SWITCH CASE

1 of
Published on Video
Go to video
Download PDF version
Download PDF version
Embed video
Share video
Ask about this video

Page 1 (0s)

[Audio] SWITCH CASE. SWITCH CASE.

Page 2 (5s)

[Audio] Presented by L.Chitra. Presented by L.Chitra.

Page 3 (12s)

[Audio] 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..

Page 4 (29s)

Syntax. Switch (expression). [Audio] Syntax Switch (expression).

Page 5 (38s)

[Audio] Here how it works: 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 expression. 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..

Page 6 (1m 27s)

Example. $day = “Wednesday” switch ($day) In this example, since the value of $day is “Wednesday,” it will execute the code in the second case block, and you’ll see “It’s hump day!” printed..

Page 7 (1m 47s)

[Audio] Thank you. Thank you.