PHP inclusione locally

35 Views Asked by At

I have the same menu for all the pages of my website. I want include it in all the page with a .php file I created with MAMP PRO a fake domani to try it locally on mu MAC.

I created my index.html and the other pages:

<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>

I created this php file:

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

After I included it on my index.html with this line rule:

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

What is wrong?

1

There are 1 best solutions below

1
On

Change extension of your index.html to index.php. An HTML file doesn't know how to execute PHP codes.

<?PHP include('menu.php'); ?> is a PHP statement but to HTML file, it's just a sentence(text)