To be able to use php code on a page with an extension other than
.php, you need a server which supports
A couple of reasons why you might want to do this are:
- You can switch to a different scripting language without breaking links.
- Security by obscurity - mask the fact that you are using PHP to generate your pages.
To add an extension to be parsed for php, create or edit a file called
.htaccess (with the dot first) containing the following line:
This tells the server to check for php code and execute it in files with extensions
.htm. So upload that .htaccess file in the same folder as your
.html files with PHP code inside them (using PHP tags:
<?php ... ?>) then when you view them in the browser, the PHP should be dealt with as you’d expect from a PHP page.