戻る

ループ処理(do while文)

JavaScript

<!DOCTYPE HTML>
<html lang="ja-JP">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
<script type="text/javascript">
var x = 0;
var str = "";

do{
	str += String(x);
	document.getElementsByTagName("body")[0].innerHTML = str;
	
	x++;
}while(x < 5);
</script>
</html>

01234

PHP

<?php
header("Content-type: text/html; charset=utf-8");

$x = 0;

do{
	echo $x;
	$x++;
}while($x < 5);
?>

01234

例:

<?php
header("Content-type: text/html; charset=utf-8");

$x = 0;
?>

<?do{?>
	<article>
		<header>…タイトル…</header>
		<section>
		…記事…
		</section>
		</footer>…投稿日…</footer>
	</article>
<?}while($x >= 1 && $x < 5);?>

inserted by FC2 system