Grazie ai cicli
while e
do-while realizza il seguente risultato:
1 * 1 = 1
2 * 1 = 2
3 * 1 = 3
4 * 1 = 4
5 * 1 = 5
6 * 1 = 6
7 * 1 = 7
8 * 1 = 8
9 * 1 = 9
10 * 1 = 10
Per la terza parte di questo esercizio, ovvero utilizzando il ciclo
for dovresti ottenere l'alfabeto inglese nella seguente formattazione:
A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-W-X-Y-Z
<!DOCTYPE html>
<html>
<head>
<title>while, do_while e for in PHP</title>
</head>
<body>
<?php
$numero = 1;
while($numero <= 10){
$risultato = 1 * $numero;
echo "$numero * 1 = $risultato<br>";
$numero++;
}
//fine ciclo "while"
echo "<br>";
$num = 1;
do {
$risultato = 1 * $num;
echo "$num * 1 = $risultato<br>";
$num++;
}while($num <= 10);
//fine ciclo do-while
echo "<br>";
for ($x='A'; $x<='Y'; $x++){
echo "$x-";
}
echo "Z";
?>
</body>
</html>