<!DOCTYPE html>
<html lang="id">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Tugas Pemrograman Web</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>

  <div class="container">
    <!-- Header Permanen -->
    <header>
      202343501561 - Adi Sarsono Sihotang
    </header>

    <!-- Sidebar Menu Permanen -->
    <aside>
      <h4>List Latihan</h4>
      <ul>
        <!-- Kirim nama file (tanpa .php) via parameter URL 'page' -->
        <li><a href="index.php?page=helloworld">Hello World</a></li>
        <li><a href="index.php?page=variabel">Variabel</a></li>
        <li><a href="index.php?page=variabel_object">Object</a></li>
        <li><a href="index.php?page=konstanta">Konstanta</a></li>
        <li><a href="index.php?page=operator_aritmatika">Operator Aritmatika</a></li>
        <li><a href="index.php?page=operator_perbandingan">Operator Perbandingan</a></li>
        <li><a href="index.php?page=operator_string">Operator String</a></li>
        <li><a href="index.php?page=kondisi_if">Kondisi If</a></li>
        <li><a href="index.php?page=kondisi_elseif">Kondisi Elseif</a></li>
        <li><a href="index.php?page=kondisi_switch">Kondisi Switch</a></li>
        <li><a href="index.php?page=while_loop">While Loop</a></li>
        <li><a href="index.php?page=do_while_loop">Do While Loop</a></li>
        <li><a href="index.php?page=for_loop">For Loop</a></li>
        <li><a href="index.php?page=foreach_loop">Foreach Loop</a></li>
        <li><a href="index.php?page=builtin_function">Built in Function</a></li>
        <li><a href="index.php?page=function_parameter">Function dengan Parameter</a></li>
        <li><a href="index.php?page=optional_argument">Optional Argumen</a></li>
        <li><a href="index.php?page=cbv">Call by Value</a></li>
        <li><a href="index.php?page=cbr">Call by Reference</a></li>
        <li><a href="index.php?page=bio">Biodata</a></li>
      </ul>
    </aside>

    <!-- Area Tengah Temporary (Memanggil File Sesuai Menu) -->
    <main id="area-konten">
      <?php
        // Cek apakah ada parameter 'page' di URL
        if (isset($_GET['page'])) {
            $page = $_GET['page'];
            $file = $page . ".php"; // Gabungkan dengan ekstensi .php

            // Periksa apakah filenya ada sebelum di-include
            if (file_exists($file)) {
                include($file);
            } else {
                echo "<p>File <b>$file</b> tidak ditemukan!</p>";
            }
        } else {
            // Tampilan default saat pertama kali website dibuka
            if (file_exists('helloworld.php')) {
                include('helloworld.php');
            } else {
                echo "Hello World!";
            }
        }
      ?>
    </main>

    <!-- Footer Permanen (Teks 2 Baris) -->
    <footer>
      <div>Pemrograman Web 2, Copyright</div>
      <div><b>202343501561 - Adi Sarsono Sihotang</b></div>
    </footer>
  </div>

</body>
</html>