Home > Backend Development > PHP Tutorial > PHP4 User Manual: Process Control-while_PHP Tutorial

PHP4 User Manual: Process Control-while_PHP Tutorial

WBOY
Release: 2016-07-13 17:22:25
Original
766 people have browsed it


while
while loop is a simple type of loop in PHP. It behaves just like in C language. The following is a basic while statement:
while (expr) statement
The meaning of this while statement is very simple. It tells PHP to execute statement(s) repeatedly as long as the while expression evaluates to true. The value of the expression is checked at the beginning of each loop. If the value of the expression is changed during execution, the program will end after evaluating the contents of the iteration. Sometimes, if the expression evaluates to FALSE from the beginning, the statement(s) will not be executed even once.
Like if statements, you can use curly braces to group multiple statements together. or by using the alternate syntax:
while (expr): statement ... endwhile;
The following two examples are the same, both output 1 to 10:
/* example 1 */$i = 1;while ($i

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532339.htmlTechArticlewhile while loop is a simple type of loop in PHP. It behaves just like in C language. The following is a basic while statement: while (expr) statement The meaning of this while statement is...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template