【发布时间】:2019-09-18 22:19:53
【问题描述】:
所以我试图将 header.php 导入到我的 index.php 文件中,但它不起作用。
header.php:
<!DOCTYPE html>
<html>
<head></head>
<body>
<header>
<p> this should be on top</p>
</header>
index.php:
<?php require "header.php"; ?>
<main>
<p> this is the index</p>
</main>
<?php require "footer.php"; ?>
页脚.php:
<p> This should be on the bottom </p>
</body>
</html>
如果我打开 index.php,它只会显示 index.php 中写的内容。 我将所有文件保存在我的桌面文件夹中的一个文件夹中。
我只需将其拖入浏览器 (firefox) 即可打开 index.php。
【问题讨论】:
-
require 给出了致命错误。你的html文件一定有问题
-
"我打开 index.php" 你怎么打开呢?
-
在我的 MAMP 服务器上运行良好。请检查以上是否保存为 .php 文件?
-
你是直接打开你的index.php文件吗?