<?php//while Loop statement
/*
1+2=3
3+3=6
6+4=10
10+5=15
15+6=21
21+7=28
28+8=36
36+9=45
45+10=55
......
*/
$a =1;//Results
$c Number of =2;//cycles
while ($c <=10) {
$b = $c; Assign the value of C to B
$a = $a + $b;//implement A+b result assignment to a a=3
$c ++;//variable c plus 1, the original 2 becomes 3.
echo "$a"; Output A in loop
echo "<br>";
}
echo "$a"; Last Output a
?>
The following Do....while loop statements
<?php
$a = 1; variable, the result of adding
$b =2;//summand Variable
do {
$a = $a + $b; The result of A+b is assigned to a
$b + +; B plus 1
echo "$a"; Outputs the value of the result variable a once per loop
echo "<br>";//newline Displays the value of each loop output
} while ($b <=100); Condition is false exit loop
echo "$a";//if the output here shows a result
?>
This article is from the "Lu Weizing blog" blog, make sure to keep this source http://ycluwq.blog.51cto.com/7588370/1582914
PHP addition increment operation method 1+2+3+4+5 ..... ......