반복문
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1>JavaScript</h1>
<ul>
<script>
i = 0;
while(i < 10){
document.write("<li>hello world</li>");
i = i + 1;
}
</script>
</ul>
<h2>php</h2>
<ul>
<?php
$i = 0;
while($i < 10){
echo "<li>hello world</li>";
$i = $i + 1;
}
?>
</ul>
</body>
</html>
- 배열 -
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1>JavaScript</h1>
<script>
list = new Array("one", "two", "three");
document.write(list[2]);
document.write(list.length);
</script>
<h1>php</h1>
<?php
$list = array("one", "two", "three");
echo $list[2];
echo count($list);
?>
</body>
</html>
- 배열 +반복문 -
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1>JavaScript</h1>
<ul>
<script>
list = new Array("최진혁", "최유빈", "한이람", "한이은", "이고잉");
i = 0;
while(i < list.length){
document.write("<li>"+list[i]+"</li>");
i = i + 1;
}
</script>
</ul>
<h1>php</h1>
<ul>
<?php
$list = array("최진혁", "최유빈", "한이람", "한이은");
$i = 0;
while($i < count($list)){
echo "<li>".$list[$i]."</li>";
$i = $i + 1;
}
?>
</ul>
</body>
</html>
'Designer_Vibi > Programming' 카테고리의 다른 글
php_기본문법 (0) | 2019.05.02 |
---|---|
PHP와 Javascript 함수/입력과 출력 (0) | 2019.05.01 |
PHP와 Javascript 동작원리 (0) | 2019.04.23 |
공유기 기본개념 (0) | 2019.04.16 |
AJAX_기본개념 (0) | 2019.04.16 |