Process control while

Loop executes
one of the computers do best feature is under a predetermined condition, repeat to perform certain actions, this is the most programming program structure can play computer expertise.
1.while statement
while (expression) {
various statements ....
}
When the expression evaluates to true, then execute the following statement block, when executed after the block of statements, continue to return to the above determination of the value of the expression true or false, or if true, then proceed to a block of statements
know that this expression evaluates to false, then the statement is executed while the end!
I = 0 $;
the while ($ I <10) {
echo ++ I $ '<br />';.
}
echo 'performed over! ';
2.Do ... while statement
do {
various statements
} while (expression);

the difference is that the while statement, do while statement is executed at least once!
3.for statement
for (expression a; B expression; expression c) {
various statements
}
expression a: it will put some initialization statement, $ i = 0, put a plurality of expressions, with intermediate, separated open
expression b: will put some used to determine true or false expressions! , You can put multiple expressions, in the middle, separated by
expressing c: will put some of variable initialization statements of self-growing! A plurality of discharge expressions, with intermediate, spaced

expression a
expression is true if b
Statement block
expression c
expression b

Guess you like

Origin www.cnblogs.com/xiaowie/p/11540281.html