I have a menu that appears on all my pages. It contains php for passing filenames to url’s as follows. Here is a snippet…
document.write('<li><a href="somefile.php?folder=<?php echo "_abc"; ?>">abc</a></li>');
document.write('<li><a href="somefile.php?folder=<?php echo "_def"; ?>">def</a></li>');
document.write('<li><a href="somefile.php?folder=<?php echo "_ghi"; ?>">ghi</a></li>');
It includes css and that works fine.
I have saved the menu as a seperate .js file and used…
<script src="js/menucss.js"></script>
…to load it from each page that I want it to appear. The menu displays and the css works fine – however the php does not parse and the page shows the php markup. What am I doing wrong?
Thanks in advance.
Neil
You shouldn’t do it like that.
Have a page called
menu.phpsaved somewhere, which includes:Then include it, on the server side (index.php):
This approach is far superior: