PHP Introductory tutorial for Loop SWICTH Tutorial

Source: Internet
Author: User

/*
for (EXPR1; expr2; expr3) {statement}

The following example is written with a for loop

The code is as follows Copy Code
<?php
for ($i = 1; $i <= $i + +) {
echo "Www.111cn.net prompts you that this is the first". $i. " Secondary cycle <br> ";
}
?>

Switch loops, which usually deal with the conditional judgment of the compound, each of which is a case instruction section. If you use many similar if instructions on the implementation, you can synthesize it into a switch loop.
The syntax is as follows:
Switch (expr) {case expr1:statement1, break, Case Expr2:statement2, break, DEFAULT:STATEMENTN, break;}
The expr condition, usually the variable name. The EXPRN after the case usually represents the value of the variable. The colon is followed by the part that meets the condition. Notice that you want to jump off the loop with a break.

  code is as follows copy code

<?php
Switch (date ("D")) {
  case "Mon":
    echo "www.111cn.net prompts you, today is Monday";
&NBSP;&N bsp;  break;
  Case "Tue":
    echo "www.111cn.net prompts you that today is Tuesday";
    break;
  Case "Wed":
    echo www.111cn.net prompts you that today is Wednesday ";
    break;
  Case" Thu " :
    echo "www.111cn.net prompts you that today is Thursday";
    break;
  Case "Fri":
    echo "www.111cn.net prompts you, today is Friday";
    break;
  Default:
    echo "www.111cn.net prompts you that today is a holiday";
    break;
}
?

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.