PHP ?? - While ??
PHP ??
??? ??? ? ??? ?? ??? ???? ???? ?? ??? ????. ????? ?? ??? ?? ?? ?? ? ???? ?? ??? ???? ??? ??? ??? ? ????.
PHP?? ??? ?? ?? ?? ????.
· while - ??? ??? true? ? ?? ?? ???
· do...while - ?? ??? ? ? ??? ?? ??? ??? true? ?? ??? ?????.
· for - ??? ???? ?? ??? ?????.
· foreach - ??? ???? ?? ??? ? ??? ?????.
PHP while ??
While? ?? ?????. while(?? ??)? ?? true?? ??? ?? ??? ?????. false? ?? ???? ?? ??? ?????.
??
while ( ??? true){
//??? ??;
}
?
?? ?? ?? ?? $x? ?????. 1???($x=1). ?? ?? $x? 5?? ??? ?? ?? while ??? ?????. ??? ??? ??? $x? 1? ?????.
<?php header("Content-type:text/html;charset=utf-8"); //設置編碼 $x=1; while($x<=5){ echo "這個數(shù)是---".$x ."<br/>"; $x++; } ?>
???? ??? ?????.
? ???---1???.
? ???---2
? ???---3
? ???---4
? ???---5
??: ?? ????? ?? ?? ??(?? ??? ?? ??)? ???? ???.
<?php
whie(1){
echo 1111.'<br / >' ??>
PHP do...while ??
do...while? while? ???? ?? ?? ?? ?? ??? ?????.
??? ?? while ??? Boolean ?? ??? ???? true?? ?????. ???? ?? ???? ???? ????.
?? do{ //?? ?? ; }while ( ??? true); ???? ?? ???? ?? ?? $x? 1($x=1)? ?????. ?? ?? do while ??? ???? ??? ?? ?? $x? 1? ??????. ?? ?? ??? ?????($x? 5?? ??? ??? ??). $x? 5?? ??? ??? ??? ?? ?????. do... while ??? ????? ? ????? ?? ??: ?? ?? do...while ??? ??? ???? ??? ??? ? ?? ?????. for ??? foreach ??? ?? ??? ???????. <?php
header("Content-type:text/html;charset=utf-8"); //設置編碼
$x=1;
do {
echo "這個數(shù)字是:$x <br>";
$x++;
} while ($x<=5);
?>
<?php
header("Content-type:text/html;charset=utf-8"); //設置編碼
$x=6;
do {
echo "這個數(shù)字是:$x <br>";
$x++;
} while ($x<=5);
?>