Central Plains University PHP video tutorial 4

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.