forとwhileの違い
Qiita投稿2回目。
for.php
<?php print('<h3>for年齢</h3>'); ?>
<form action="output.php" method="get" accept-charset="utf-8">
<select name="age" id="age">
<?php
for ($i=10; $i<=70; $i++) {
print('<option value="'.$i.'">'.$i.'歳</option>'); # code...
}
?>
</select>
<input type="submit" value="送信する" />
</form>
while.php
<form action="output.php" method="get" accept-charset="utf-8">
<?php print('<h3>while年齢</h3>'); ?>
<select name="age" id="age">
<?php
$i=10;
while ($i <=70) {
print('<option value="'.$i.'">'.$i.'歳</option>');
$i++;
}
?>
</select>
<input type="submit" value="送信する" />
</form>