/*
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;
}
? |