我正在学习PHP,现在我正在学习如何添加文件。
然而,
我无法导入例如我的header.php到我的index.php文件中。
我的浏览器卡住了,没有显示任何内容。
我有两个php文件;我试图包含在index.php中的footer.php和header.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>
的header.php
<?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 -->
' ?>
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>
'
?>
答案 0 :(得分:1)
头:
<?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>
';
?>
答案 1 :(得分:1)
您实际上不需要在 footer.php 和 header.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>
<强>的header.php 强>
<!-- 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 -->