In this tutorial you will learn about the different ways of executing PHP code into HTML pages. In general, we have seen that a page that includes the php code is always named as “. php” because it is the extension of the php file. But in case you do not wanted to change the file name just change the “.htaccess file” and add the following line into it…1. For HTML
2. For HTM
AddType application/x-httpd-php .htm
There is one more way of doing it… creates a new .php page and add the given lines
<Files my-html-page.html>Add Type application/x-httpd-php.html</Files>
This will make you run your PHP code in .html (my-html-page.html) file.
In the foregoing paragraph we have seen how to execute php in html page. Now lets find out the reason of doing it…
But I believe that it’s better to change the extension of a page as .php, if we want a dynamic website with lot’s of programming features. This process is know as embedding PHP code in html file, you will learn about it in the next article.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.