【发布时间】:2018-05-22 15:16:12
【问题描述】:
我刚开始在家创建网站。
当然,我必须拥有这两个页面才能快速完成我的网站:- footer.php、header.php。
所以我创建了这些页面并放置了一些内容。还在htdocs 文件夹内创建了一个索引页为index.php。
然后我确实使用以下代码在index.php 页面中包含了header 和footer 页面。
<?php include 'header.php'; ?>
<?php include 'footer.php'; ?>
毫无疑问,它们运行良好,没有任何问题。
然后我在htdocs 中创建了一个目录为account。
现在我在 account 目录 (/account/login.php) 中有一个 login.php 页面。
我多次使用相同的代码在登录页面中包含header 和footer。但他们没有工作!我看到什么都没有发生。如果我在htdocs 文件夹中(不在htdocs/account/ 中)创建login.php 页面,那么它可以工作。
那么,当登录页面位于account 目录中时,如何包含它们?
【问题讨论】:
-
试试 你必须返回一个文件夹
-
你在包含中使用相对路径吗?例如
<?php include '../header.php'; ?>
标签: php header directory include footer