COMPUTER LEARNING CENTER
WWW.HUUKHANG.COM
break;
case 5:
$str="Today
is
Friday";
break;
case 6:
$str="Today
is
Saturday";
break;
default:
$str="Today
is
Sunday";
break;
}
echo
$str;
?>
</BODY>
</HTML>
4.5.
Phaùt bieåu While(ñieàu kieän)
Phaùt bieåu while thöïc thi nhöõng caâu leänh trong while khi ñieàu kieän coù giaù trò
true.
Ví duï 3.11: Phaùt bieåu While
<HTML>
<HEAD>
<TITLE>::Welcome to PHP</TITLE>
</HEAD>
<BODY>
<h4>While Statement</h4>
<?php
$j=10;
while($j>0)
{
echo
$j."<br>";
$j--;
}
?>
</BODY>
</HTML>
4.6.
Phaùt bieåu For
Phaùt bieåu for duøng cho voøng laëp coù giôùi haïn cho tröôùc, cuù phaùp coù daïng nhö
sau:
Ví duï 3.12: Phaùt bieåu For
<HTML>
<HEAD>
3-10