Cyclic structure learning objectives: while doing and for understanding their characteristics, and differences, remember several conditions of the loop. See code: <? The php//while condition is true before running. $i =0;while ($i <=10) {echo $i + +, ' <br/> '; Print out 0 to ten}//while ' when ' meaning. This expression means that when the value in parentheses is true, it is executed until it is false. So, we constantly change the value, let it stop for a fake. This is a loop. If the do condition is true or FALSE, perform a $i=100;do{echo ' I will do it once ';} while ($i <10); <? General elements of the Php/*for cycle: initialization (1), judging (2), Actuator (3), modifying variable (4) for (1;2;4) {3} *///For example: Rich people drink, ¥10w each drink 3W question: How many drinks can I have? Analysis: Initialize $I=10 judge each time to 3W, indicating $i>3 every drink, money will be reduced 3w//so $i-=3; ($i-=3 equals $i= $i-3 This is a shorthand) for ($i =10; $i >3; $i-=3) {echo ' drinks ';//print: Drink and drink drink}echo ' <br/> '; For ($i =1, $j =5; $i <=5&& $j >=1; $i + +, $j-) {echo $i, $j, ' <br/> ';//print: 15 24 33 42 51 * This example is very important, when you know it's going to be written. , you will understand the For loop. }
Five. PHP language structure (2) loop structure