I'm trying to include my menu.php in many html files. I followed instructions online, but can't display menu
this is my menu file
<li><a href="index.php">Home</a></li>
<li><a href="about.php">About Us</a></li>
<li><a href="products.php">Products</a></li>
<li><a href="services.php">Services</a></li>
and this is how i try to include it in files
<!DOCTYPE html>
<html>
<body>
<?php include "includes/menu.php"; ?> // OR <ul id="navigation"><?php include("includes/menu.php"); ?></ul>
<p>Some text.</p>
</body>
</html>
Something doesn't work as I either get no menu bar or get just code written in a file. Not sure what I'm doing wrong.
Either way (with or without parenthesis) is okay - but make sure your path is correct -
if you use require
- it'll fire an error, and if error reporting is turned on, you'll be able to see the full path that it is trying to include your menu.php
from -
Otherwise, it is generally a good rule of thumb to include the full path:
include "/absolute/path/to/includes/menu.php";