Php – Switch Case Conditional Statements

RSS
FACEBOOK
FACEBOOK
PINTEREST
PINTEREST
LINKEDIN
INSTAGRAM

[rps-include post=6522]

In previous post we have learned how if-elseif-else conditional statement works. Php provides one more conditional statement named switch-case . switch-case statements generally used for more precise and deterministic decisions. We generally check if given value fully matches with given single value in each statement.

Syntax of switch-case is like below.

As we can see from syntax we provide VARIABLE and look for each case if LABEL matches with VARIABLE . If matches the CODE is executed and break finishes case code block and exits switch .

This example will print Open because the case condition matches with it.

[rps-include post=6522]

RSS
FACEBOOK
FACEBOOK
PINTEREST
PINTEREST
LINKEDIN
INSTAGRAM
LEARN MORE  How to Configure Cisco Device and User Modes

Leave a Reply

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

Enjoy this blog? Please spread the word :)