繁体   English   中英

链接到另一个php页面并包含页眉和页脚

[英]linking to another php page and include header and footer

我是初学者,只是想学习php。 下面是我的index.php文件:

<?php
  include("header.php");
  require_once('connect.php');
  include("home.php");
  include("footer.php");
?>

我创建了一个简单的测试站点,其中包含index.php文件中的主页。 我必须使用include(header.php); 如果我想包含相同的代码,在每个页面上? 谢谢。

你没有在每个页面上包含header.php。 尝试这个:

<?php include("header.php");?>
<div class="container">
   <?php include ("home.php");?>
</div>
<?php include ("footer.php");?>

保持页眉和页脚,只需更改内容(home.php,otherpage.php,...)。 我建议你使用jQuery动态加载container的内容

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM