조건문 / 배열과 반복문
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello world</title>
</head>
<body>
<?php
$result = (1 == 1);
if ($result) {
echo "참";
} else {
echo "거짓";
}
$list = array("one", "two", "three");
echo $list[2];
echo count($list);
?>
<ol>
<?php
$i = 0;
while ($i < 10) {
echo "<li>hello world</li>";
$i = $i + 1;
}
?>
</ol>
<ul>
<?php
$list2 = array("one", "two", "three");
$j = 0;
while ($j < count($list2)) {
echo "<li>" . $list2[$j] . "</li>";
$j = $j + 1;
}
?>
</ul>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Hello world</title>
</head>
<body>
<script>
result = 1 == 1;
if (result) {
document.write("참");
} else {
document.write("거짓");
}
list = new Array("one", "two", "three");
document.write(list[2]);
document.write(list.length);
</script>
<ol>
<script>
j = 0;
while (j < 10) {
document.write("<li>hello world</li>");
j = j + 1;
}
</script>
</ol>
<ul>
<script>
list2 = new Array("one", "two", "three");
j = 0;
while (j < list2.length) {
document.write("<li>" + list[j] + "</li>");
j = j + 1;
}
</script>
</ul>
</body>
</html>
간단한 로그인 기능 구현하기
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello world</title>
</head>
<body>
<?php
$pwd = $_GET["pwd"];
if($pwd == 1111){
echo "안녕하세요.";
} else {
echo "다시 입력해주세요.";
}
?>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello world</title>
</head>
<body>
<script>
pwd = prompt("비밀번호를 입력하세요.");
if(pwd == 1111){
document.write("안녕하세요.");
} else {
document.write("다시 입력해주세요.");
}
</script>
</body>
</html>
함수
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Hello world</title>
</head>
<body>
<?php
function hello()
{
echo "Hello!!!";
}
hello();
function add($a, $b)
{
echo $a + $b;
}
add(2, 5);
?>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Hello world</title>
</head>
<body>
<script>
function hello() {
document.write("Hello!!!");
}
hello();
function add(a, b) {
document.write(a + b);
}
add(2, 5);
</script>
</body>
</html>