如何制作标题和侧边栏?

时间:2022-11-05 23:06:12

This is my index.php file

这是我的index.php文件

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <style type="text/css">
    </style>
</head>
<body>
   <div id="container">
   <?php
    include('includes/header.php');
    include('includes/sidebar.php');
    include('includes/content.php');
    include('includes/footer.php');
?>
</body>
</html>

This is code for my sidebar.php

这是我的sidebar.php的代码

<div id="sidebar">
<ul id="list">
    <li><a href="index.php" class="sidebar">Home</a></li>
    <li><a href="flower.php" class="sidebar">flower</a></li>
    <li><a href="study.php" class="sidebar">Study</a></li>
    <li><a href="calendar.php" class="sidebar">Calendar</a></li>
    <li><a href="diary.php" class="sidebar">Diary</a></li>
</ul>

if I click flower, it will go to flower.php. I didn't include header, sidebar, and footer, and found that it shows only contents of flower.php, not showing header, sidebar, and footer. Is there any way to make it showing? Or should I just write down all the code below again?

如果我点击花,它将转到flower.php。我没有包含标题,侧边栏和页脚,并发现它只显示了flower.php的内容,没有显示标题,侧边栏和页脚。有没有办法让它显示出来?或者我应该再次写下以下所有代码?

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <style type="text/css">
    </style>
</head>
<body>
   <div id="container">
   <?php
    include('includes/header.php');
    include('includes/sidebar.php');
    include('includes/content.php');
    include('includes/footer.php');

1 个解决方案

#1


1  

You should use your header, footer and sidebar on each of your page, because it won't create any problem because if you need to make change you would only change in required file and the change will occur in all other files as well. While content.php you should have your specific code for each page separately. Hope this help

您应该在每个页面上使用页眉,页脚和侧边栏,因为它不会产生任何问题,因为如果您需要进行更改,您只需要更改所需的文件,并且更改也将在所有其他文件中进行。在content.php中,您应该分别为每个页面分配特定的代码。希望这有帮助

#1


1  

You should use your header, footer and sidebar on each of your page, because it won't create any problem because if you need to make change you would only change in required file and the change will occur in all other files as well. While content.php you should have your specific code for each page separately. Hope this help

您应该在每个页面上使用页眉,页脚和侧边栏,因为它不会产生任何问题,因为如果您需要进行更改,您只需要更改所需的文件,并且更改也将在所有其他文件中进行。在content.php中,您应该分别为每个页面分配特定的代码。希望这有帮助