<?php
$num = $_GET['num'];
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<title>ループ</title>
</head>
<body>
<h1>連呼プログラム</h1>
<form action="" method="get">
何回連呼しますか?
<input type="number" name="num" max="10" min="0">
<div><input type="submit" value="決定"></div>
</form>
<?php
//while1ループ☆
$count = 0; //count変数の初期化
if($count < $num){
?>
<p><?php print $count+1;?>.超!(while)</p>
<?php
$count++; //count変数インクリメント
}
//while2ループ
$count = 0; //count変数の初期化
while(true){ //無限ループ
if($count >= $num){ //$countが$num以上になったら
break; //ループから抜ける
}
?>
<p style="font-size:1.2em"><?php print $count+1;?>.超(while,break)</p>
<?php
$count++; //count変数インクリメント
}
//do-whileループ
$count = 0;; //count変数の初期化
do{
?>
<p style="font-size:1.5em"><?php print $count+1;?>.超(do-while)</p>
<?php
$count++; //count変数インクリメント
}while($count < $num);
//forループ☆
($i = 0; $i < $num; $i++){ //count変数(ここでは$i)の初期化からインクリメントまで1行で書ける
?>
<p style="font-size:1.8em"><?php print $i+1;?>.いい感じ!(for)</p>
<?php
}
?>
</body>
</html>