Execute PHP scripts within html files

Most of us have come across a problem where we are having a bundle of html pages and suddenly we are in need to add some logic or some kind of php script to do something that cannot be handled by HTML or JavaScript.

The below piece of code will help you in executing php code blocks or scripts from within the html file. To do this, all you need is the access to .htaccess file. If it’s not there, create a file .htaccess and place the following code.. you will see the magic 🙂

RemoveHandler .html .htm
AddType application/x-httpd-php .php .html .htm

Good Luck (Y)