DB/๐PHP
๐์น์ฌ์ดํธ์ ๋นํ์ธ๋ PHP : ํจ์ ๋ง๋ค๊ธฐ
4:Bee
2023. 9. 5. 04:48
728x90
| YouTube Link | |
| EB2-PHP-18-แแ กแทแแ ฎ แแ กแซแแ ณแฏแแ ต แแ จแแ ฉphp | |
| https://youtu.be/XAVYo8uLlWM?si=3HttPRLe-TMgHK7x |
| YouTube Link | |
| WEB2-PHP-19.1.แแ กแทแแ ฎแแ ด แแ งแผแแ ตแจ 1/3 | |
| https://youtu.be/gfCyAy_kE7M?si=d6R5KCZohxQLs_C- |
| YouTube Link | |
| WEB2-PHP-19.1.แแ กแทแแ ฎแแ ด แแ งแผแแ ตแจ 2/3 | |
| https://youtu.be/g1oXQ5hBDsc?si=Gk09sXqStA1wRlAD |
| YouTube Link | |
| WEB2-PHP-19.1.แแ กแทแแ ฎแแ ด แแ งแผแแ ตแจ 3/3 | |
| https://youtu.be/1JrU2jWH2h0?si=ltsxspH2Ofs2Mh14 |
| YouTube Link | |
| WEB2-PHP.20.แแ กแทแแ ฎแแ ด แแ ชแฏแแ ญแผ | |
| https://youtu.be/P6tQrxmLkhY?si=mvuofDy90SmRJBiQ |
<?php
function print_title()
{
if (isset($_GET['id'])) {
echo $_GET['id'];
} else {
echo "Welcome";
}
}
function print_description()
{
if (isset($_GET['id'])) {
echo file_get_contents("data/" . $_GET['id']);
} else {
echo "Hello, PHP";
}
}
function print_list()
{
$list = scandir('data'); // ํด๋น ๋๋ ํ ๋ฆฌ ์์ ์๋ ํ์ผ์ list๋ผ๋ ๋ณ์ ์์ ๋ด์ ๋๋ค.
$i = 0;
while ($i < count($list)) {
//count ํจ์๋ฅผ ํตํด์ ํด๋น list์ leng๊ธธ์ด๋ฅผ
if ($list[$i] != '.') {
if ($list[$i] != '..') {
?>
<li><a href="index.php?id=<?= $list[$i] ?>"><?= $list[$i] ?></a></li>
<?php
}
}
$i = $i + 1;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
<?php
print_title();
?>
</title>
</head>
<body>
<h1><a href="index.php">WEB</a></h1>
<ol>
<?php
print_list();
?>
</ol>
<h2>
<?php
print_title();
?>
</h2>
<?php
print_description();
?>
</body>
</html>
php์ ํจ์๋ ๋ค๋ฅธ ์ธ์ด์์๋ ์ฌ์ฉํ๋ ํจ์์ ํ์์ ๊ฐ์ง๊ณ ์๊ธฐ์ ์ด๋ฒ ๊ฐ์๋ ํฌ๊ฒ ์ด๋ ค์ด ์ ์ด ์๋ค. ๊ฐ์๋ฅผ ํธ์ํ๊ฒ ๋ค์ผ๋ฉด์ ์ค์ตํด๋ณด๋ฉด ์ข์ ๋ฏํ๋ค.
728x90