I am just starting to learn PHP and many of the tutorials that I have come across provide sample code to be embedded into your .htm file. To me, this implies that the server should be able to recognize that the parsed PHP code, delineated by it's <? and ?>, and process that along with the html.
When I try this on my server, however, it doesn't work (although it works fine if I rename the file to something.php instead of something.htm)
I would rather use .htm extension though, as I think it's better for search engines and I don't care to notify folks that I'm doing anything dynamic in the background by having the php extension.
I was able to get this to work by modifying my .htaccess file to add a line as follows:
1) Is it normally necessary to add this line to your .htaccess file in order to process PHP in .htm files?
2) Is there any reason NOT to add this line to my .htaccess file? In other words, is there any reason (performance, security, whatever..) why I wouldn't want my server to process .htm files with PHP code in them?
As I mentioned, I'm just getting started with this so forgive me if the question seems a bit inane..
> Is it normally necessary to add this line to your .htaccess file
You need to tell the server which files to run through the PHP engine, and that is the way you do it.
> Is there any reason NOT to add this line to my .htaccess file
You'll take a performance hit on non-PHP .htm pages as they'll still be parsed for PHP coding. If most of your pages are straight HTML then you'd probably be better off putting your PHP pages in a seperate directory and only putting the .htaccess file in there.