PHP4 User Manual: Process control-while. A whilewhile loop is a simple type in a PHP loop. Its behavior is just like in c. The following is a basic while statement: while (expr) statement, the meaning of the while statement is
A while loop is a simple type in a PHP loop. Its behavior is just like in c. The following is a basic while statement:
While (expr) statement
The meaning of this while statement is very simple. It tells PHP to repeat statement (s) as long as the while expression value is true ). At the beginning of each loop, the value of the expression is checked. if the value of this expression is changed during execution, the program will end after an urgent repetition. Sometimes, if the expression value is FALSE from the beginning, statement (s) will not be executed once.
Like if statements, you can enclose multiple statements in a group with braces. Or by using the alternate syntax:
While (expr): statement... endwhile;
The two examples below are the same and both output 1 to 10:
/* Example 1 */$ I = 1; while ($ I <= 10) {print $ I ++; /* the printed value wocould be $ I before the increment (post-increment) */}/* example 2 */$ I = 1; while ($ I <= 10 ): print $ I; $ I ++; endwhile;
A while loop of http://www.bkjia.com/PHPjc/532339.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/532339.htmlTechArticlewhile is a simple type in a PHP loop. Its behavior is just like in c. The following is a basic while statement: while (expr) statement the meaning of the while statement is...