Http://www.linji.cn/1104.htm
Switch incircle
Switch condition ring. Generally, this condition is used to determine the condition. Each sub-condition is a case command section. In practice, if you use many similar if commands, You can merge them into the switch ring.
The signature method is as follows:
Switch (expr ){
Case expr1:
Statement1;
Break;
Case expr2:
Statement2;
Break;
:
:
Default:
StatementN;
Break;
}
The expr condition usually changes the data name. The exprN after case usually represents the variable value. The region where the condition is to be confirmed. Note that you need to use break to skip the lap.<? Php
Switch (date ("D ")){
Case "Mon ":
Echo "Monday, monkey wearing new clothes ";
Break;
Case "Tue ":
Echo "today, Tuesday, monkey belly ";
Break;
Case "Wed ":
Echo "on Wednesday, monkeys go hiking ";
Break;
Case "Thu ":
Echo "today, Thursday, monkey watching TV ";
Break;
Case "Fri ":
Echo "today Friday, monkeys go dancing ";
Break;
Default:
Echo "Today's holiday, no matter the Monkey ";
Break;
}
?>
Obviously, the above example is very difficult to use if Else. When designing a program, you can increase the program's failover efficiency by placing the most outgoing and outgoing conditions at the bottom. The previous example shows the same machine rate every day, so you do not need to pay attention to the reverse order of the condition.