Я получил ответ от своего учителя.Я хотел бы поделиться этим с вами.
Это из multipage.php:
<?php
$pageReference = $_GET["page"] ?? "index";
$multiPages = [
"index" => [
"title" => "Intro",
"subpage" => __DIR__ . "/multipage/index.php",
],
"print-get" => [
"title" => "Print variable",
"subpage" => __DIR__ . "/multipage/print-get.php",
]
];
$newPage = $multiPages[$pageReference] ?? null;
if (!$newPage) {
die("Fel, fel, fel...");
}
$title = "{$newPage['title']}";
$m_subpage = $newPage["subpage"];
include __DIR__ . "/view/header.php";
include __DIR__ . "/view/multi_page.php";
include __DIR__ . "/view/footer.php";
Из представления / multi_page.php:
<div class="wrap-main">
<h2>Multipage</h2>
<?php include __DIR__ . "/multi_aside.php"; ?>
<article class="subpage">
<?php if ($pageReference) : ?>
<?php require $m_subpage; ?>
<?php else : ?>
<p>You have selected something '<?= htmlentities($pageReference) ?>' that
does not map to an actual page.</p>
<?php endif; ?>
</article>
</div>
Из multipage_aside.php:
<aside>
<ul class="aside">
<?php foreach ($multiPages as $key => $value) : ?>
<?php
$selected = null;
if ($key === $pageReference) {
$selected = "class='selected'";
}
?>
<li><a <?= $selected ?> href="?page=<?= $key ?>"><?= $value["title"] ?></a></li>
<?php endforeach; ?>
</ul>
</aside>
И, наконец, CSS:
.aside .selected {
color: purple;
font-weight: bolder;
text-decoration: underline;
}