JavaScript/PHP ๋ฐฐ์ด&๋ฐ๋ณต๋ฌธ ๋น๊ต
๋ฐ๋ณต๋ฌธ
<!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>