I'm fairly new to php, and I'm sure this is something simple. I have a php file named footer.php that contains the code I want at the end of every page, so I want to use an include function to do it. The file looks like this:
<?php
echo "<p>Copyright © 1999-" . date("Y") . " W3Schools.com</p>";
?>
I then, in my main form, use an include statement like this:
<html>
<body>
//other code//
<?php include('footer.php');?>
</body>
</html>
The //other code// is stuff that isn't relevant and works fine.
I have my wamp server on, and both files are in the www folder in it. Any ideas why the include footer isn't showing up in my main file? I'm not getting any error messages in the log. Do I need to go into phpmyadmin or something?
Does your main file have a .php extension? If it is set to for instance index.html, the PHP include will not be executed and you will just see the HTML with no errors logged.
Is your main form file saved with a .php extension?
You can also try
<?php require_once "footer.php"; ?>