Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
插入Php文件_Php_Html_Include - Fatal编程技术网

插入Php文件

插入Php文件,php,html,include,Php,Html,Include,我正在学习PHP,现在我正在学习如何添加文件 但是, 例如,我在将header.php导入index.php文件时遇到问题 我的浏览器无法加载,并且没有显示任何内容 我有两个php文件;一个footer.php和一个header.php,我正试图将它们包含到index.php中 这是我的密码 Index.php <html> <head> <title><?php echo $page['title'];?></title> &

我正在学习PHP,现在我正在学习如何添加文件

但是,

例如,我在将header.php导入index.php文件时遇到问题

我的浏览器无法加载,并且没有显示任何内容

我有两个php文件;一个footer.php和一个header.php,我正试图将它们包含到index.php中

这是我的密码 Index.php

<html>
<head>
    <title><?php echo $page['title'];?></title>
</head>
<body>
<div class="headerr">
<?php
  $page = array();
  include 'footer.php';
?>
</div>
<div>
    <h1>
        Hola
    </h1>
    <article>
        Nulla mauris odio, vehicula in, condimentum sit amet, tempus id, metus. Donec at nisi sit amet felis blandit posuere. Aliquam erat volutpat. Cras lobortis orci in quam porttitor cursus. Aenean dignissim. Curabitur facilisis sem at nisi laoreet placerat. Duis sed ipsum ac nibh mattis feugiat. Proin sed purus. Vivamus lectus ipsum, rhoncus sed, scelerisque sit amet, ultrices in, dolor. Aliquam vel magna non nunc ornare bibendum. Sed libero. Maecenas at est. Vivamus ornare, felis et luctus dapibus, lacus leo convallis diam, eget dapibus augue arcu eget arcu.
    </article>
</div>
<div class="footterr">
<?php
 include 'footer.php';
?>
</div>
</body>
</html>

赫拉
' ?>
footer.php

<?php echo'
<!-- footer begins -->
<br />
<center>Your usage of this site is subject to its published <a href="tac.html">terms and conditions</a>. Data is copyright Big Company Inc, 1995-<?php echo date("Y", mktime()); ?></center>

'
?>

您在页眉和页脚上忘记了分号。而且,您不需要重新打开php in footer for time函数(只需将其附加到文本中)

标题:

<?php echo '
<!-- top menu bar -->
<table width="90%" border="0" cellspacing="5" cellpadding="5">
    <tr>
        <td><a href="#">Home</a></td>
        <td><a href="#">Site Map</a></td>
        <td><a href="#">Search</a></td>
        <td><a href="#">Help</a></td>
    </tr>
</table>

<!-- header ends -->
'; ?>

页脚:

    <?php echo'
    <!-- footer begins -->
    <br />
    <center>Your usage of this site is subject to its published <a href="tac.html">terms and conditions</a>. Data is copyright Big Company Inc,  1995-' . date("Y", mktime()) . '
</center>
     ';
        ?>


您实际上不需要在footer.phpheader.php上使用echo。我觉得你的index.php很好

footer.php

<!-- footer begins -->
<br />
<center>Your usage of this site is subject to its published <a href="tac.html">terms and conditions</a>. Data is copyright Big Company Inc, 1995-<?php echo date("Y", mktime()); ?></center>
<!-- top menu bar -->
<table width="90%" border="0" cellspacing="5" cellpadding="5">
  <tr>
    <td><a href="#">Home</a></td>
    <td><a href="#">Site Map</a></td>
    <td><a href="#">Search</a></td>
    <td><a href="#">Help</a></td>
  </tr>
</table>
<!-- header ends -->


您对本网站的使用取决于其发布的版本。数据版权归大公司所有,1995年-
header.php

<!-- footer begins -->
<br />
<center>Your usage of this site is subject to its published <a href="tac.html">terms and conditions</a>. Data is copyright Big Company Inc, 1995-<?php echo date("Y", mktime()); ?></center>
<!-- top menu bar -->
<table width="90%" border="0" cellspacing="5" cellpadding="5">
  <tr>
    <td><a href="#">Home</a></td>
    <td><a href="#">Site Map</a></td>
    <td><a href="#">Search</a></td>
    <td><a href="#">Help</a></td>
  </tr>
</table>
<!-- header ends -->


因此,您想要回显的php没有显示,或者您的整个页面现在为空?页眉和页脚都缺少
回显后的分号。FWIW您似乎正在将页脚导入页面的顶部和底部。@MikeW我不确定是否需要分号。我经常使用
而不使用半成品-colon@MikeW只是在当地试过。你一定在代码板上做了些别的事情,因为它对我来说很好~BINGO-好了。你不能用那种方式访问那些文件。PHP需要安装并正确配置(如果它没有安装,我倾向于认为它没有安装),否则它们将无法正确解析。PHPStorm是一个编辑器,而不是一个解析器/浏览器。我不完全确定在这种情况下是否需要它们。
?>
分隔符通常足以表示语句结束,谢谢eddie,但它仍然没有加载。我正在使用PHPstorm,我转到chrome,它在浏览器中打开,但页面上没有显示任何内容,选项卡中有加载动画。@av17,当您从索引中删除include'footer.php'和'header.php'时,您的页面加载了吗?谢谢Eddie(:您修复了它。感谢您成为我的第一个upvotePerhaps,这是一条评论?