PHP Switch Statement

This statement is used if one needs to select one from multiple options.

Syntax:

switch (x) {
case label1:
code to be executed if x=label1;
break;
case label2:
code to be executed if x=label2;
break;
case label3:
code to be executed if x=label3;
break;

default:
code to be executed if x is different from all labels;
}

Example:

Result:
I booked Swift

Leave a Reply

Your email address will not be published.