-2

我网站的所有页面都有相同的菜单。我想将它包含在所有页面中,其中包含我用 MAMP PRO 创建的一个假 domani 的 .php 文件,以便在 mu MAC 上本地尝试它。

我创建了 index.html 和其他页面:

<html>
 <header>
    <title>Inclusion test</title>
</header>  

<body>

    <ul>
        <li><a href="index.html">Home</a></li>
        <li><a href="pippo.html">Pippo</a></li>
        <li><a href="pluto.html">Pluto</a></li>
    </ul> 

    <h1>Welcome on Disneyland!</h1>


</body> 

</html>

我创建了这个 php 文件:

   <?php
   echo "<a href="index.html">Home</a>";
   "<a href="pippo.html">Pippo</a>";
   "<a href="pluto.html">Pluto</a>";
   ?>

在我用这条线规则将它包含在我的 index.html 中之后:

<?php include 'menu.php';?>

怎么了?

4

1 回答 1

0

将您的扩展名更改index.htmlindex.php. HTML 文件不知道如何执行 PHP 代码。

<?PHP include('menu.php'); ?>是一个 PHP 语句,但对于 HTML 文件,它只是一个句子(文本)

于 2014-08-05T09:53:46.667 回答