while

(PHP 4, PHP 5, PHP 7)

while 循锟斤拷锟斤拷 PHP 锟斤拷锟斤拷虻サ锟窖拷锟斤拷锟斤拷汀锟斤拷锟斤拷锟� C 锟斤拷锟斤拷锟叫碉拷 while 锟斤拷锟街碉拷一锟斤拷锟斤拷while 锟斤拷锟侥伙拷锟斤拷锟斤拷式锟角o拷

while (expr)
    statement

while 锟斤拷锟侥猴拷锟斤拷芗虻ィ锟斤拷锟斤拷锟斤拷锟� PHP 只要 while 锟斤拷锟绞斤拷锟街滴� TRUE 锟斤拷锟截革拷执锟斤拷嵌锟斤拷锟叫碉拷循锟斤拷锟斤拷洹o拷锟斤拷式锟斤拷值锟斤拷每锟轿匡拷始循锟斤拷时锟斤拷椋拷锟斤拷约锟绞癸拷锟斤拷值锟斤拷循锟斤拷锟斤拷锟斤拷懈谋锟斤拷耍锟斤拷锟斤拷也锟斤拷锟斤拷停止执锟叫o拷直锟斤拷锟斤拷锟斤拷循锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷时锟斤拷锟斤拷锟� while 锟斤拷锟绞斤拷锟街狄伙拷锟绞硷拷锟斤拷锟� FALSE锟斤拷锟斤拷循锟斤拷锟斤拷锟揭伙拷味锟斤拷锟斤拷锟街达拷小锟�

锟斤拷 if 锟斤拷锟揭伙拷锟斤拷锟斤拷锟斤拷锟斤拷锟� while 循锟斤拷锟斤拷锟矫伙拷锟斤拷锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷椋拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤法锟斤拷

while (expr):
    statement
    ...
endwhile;

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷全一锟斤拷锟斤拷锟斤拷锟斤拷示锟斤拷锟斤拷 1 锟斤拷 10锟斤拷

<?php
/* example 1 */

$i 1;
while (
$i <= 10) {
    echo 
$i++;  /* the printed value would be
                    $i before the increment
                    (post-increment) */
}

/* example 2 */

$i 1;
while (
$i <= 10):
    print 
$i;
    
$i++;
endwhile;
?>