99乘法表的3种写法 while和do...while和for
do...while的九九乘法表
<?php
header("Content-type:text/html;charset=utf-8");
$i=1;
do{
$j=1;
do{
echo $i . '*' . $j .'='. $i*$j . ' ';
$j++;
}
while($j<=$i);
echo '<br>';
$i++;
}
while($i<=9)
?>
for 语句的写法
<?php
header("Content-type:text/html;charset=utf-8");
for($i=1;$i<=9;$i++){
for($j=1;$j<=$i;$j++){
echo"$j*$i"."=".$i*$j." ";
}
echo"<br>";
}
?>
while的九九乘法表
<?php
header("Content-type:text/html;charset=utf-8");
$i=1;
while($i<=9){
$j=1;
while($j<=$i){
echo"$j*$i"."=".$i*$j." ";
$j++;
}
echo"<br>";
$i++;
}
?>
<?php
header("Content-type:text/html;charset=utf-8");
$i=1;
do{
$j=1;
do{
echo $i . '*' . $j .'='. $i*$j . ' ';
$j++;
}
while($j<=$i);
echo '<br>';
$i++;
}
while($i<=9)
?>
for 语句的写法
<?php
header("Content-type:text/html;charset=utf-8");
for($i=1;$i<=9;$i++){
for($j=1;$j<=$i;$j++){
echo"$j*$i"."=".$i*$j." ";
}
echo"<br>";
}
?>
while的九九乘法表
<?php
header("Content-type:text/html;charset=utf-8");
$i=1;
while($i<=9){
$j=1;
while($j<=$i){
echo"$j*$i"."=".$i*$j." ";
$j++;
}
echo"<br>";
$i++;
}
?>