I want a php file to be included to display a footer of my web pages. I’m using godaddy shared hosting with php7.4.
I created a footer.php file like thus:
<?php
echo "<p>Copyright © 1999-" . date("Y") . " W3Schools.com</p>";
?>
A html file "test.html" to display the footer is like thus:
<html>
<body>
<h1>Welcome to my home page!</h1>
<p>Some text.</p>
<p>Some more text.</p>
<?php include 'footer.php';?>
</body>
</html>
The result displays the test.html file without the footer file display.
Thanks in advance for any positive solutions.
Cheers,
Dave
As stated above, it didn’t display the footer file verbiage.
2
Answers
Modify you code as below in html files
Make Bulk file replace in any notepad ++ like editor with
replace in file
Your php include file line
with
Other method is to make apache interpret html files as php
refer to this link
https://www.plesk.com/kb/support/how-to-configure-apache-to-process-php-code-inside-an-html-file-on-a-plesk-server/
This is not just for plesk server but can be used for any apache based server if you have access to these files.
For your informaton, HTML file cannot render PHP commands under normal circumstances.
However, you may use a small trick to do the job
Assuming that your footer is a php (footer.php)
Then you may use
So the code will be:
So the following will be a sample:
The result will be like: