关于循环,IF,WHILE。。。。
<?php $month = date("n"); $today = date("j"); if ($today >= 1 and $today <= 10){ echo "今天是".$month."月".$today."日上旬"; }elseif($today > 10 and $today <= 20){ echo "今天是".$month."月".$today."日中旬"; }else{ echo "今天是".$month."月".$today."日下旬"; } echo "<br>"; $num = 1; $str = "10以内的偶数为:"; while ($num <= 10){ if ($num % 2 == 0){ $str.=$num." "; } $num++; } echo $str; echo "<br>"; $flag = 1; while ($flag != 1){ echo "不会看到"; } do{ echo "会看到"; }while ($flag != 1); echo "<br>"; $sum = 1; for ($i = 1; $i <= 100; $i++){ $sum *= $i; } echo "100! = ".$sum; echo "<br>"; while (true){ $tmp = rand(1,20); echo $tmp." "; if ($tmp == 10){ echo "<p>变量等于10,终止循环"; break; } } ?>