I’ve searched the SitePoint archives and found a few topics, but all are at least 4 years old.
I have a site where I’d like to continue using the (well established) .html file extensions, but also use php includes for shared elements. I’m very new to PHP and I was wondering whether there’s an accepted best practice for having Apache parse PHP within HTML documents.
They are the same method, the control panel is just doing the file editing for you. In either case, you’re adding an AddHandler directive to your web server configuration telling it to pass .htm/.html files to the PHP interpreter.
Parsing .html files as PHP does not incur a performance penalty vs. parsing .php files as PHP per se. However, the server will parse all HTML documents as PHP, whether they contain PHP code or not. That may or may not cause unacceptable overhead.
Considering that using a PHP CMS or creating a new PHP website is as common, or more common, than writing HTML files these days, it’s hard to think of a situation where that would cause unacceptable overhead. It wouldn’t with any normal sized website on any standard web host at least.
Don’t confuse “server-parsed HTML”, i.e., Server Side Includes (SSI) with PHP parsing. Ultimately, Apache must be aware that it is supposed to use PHP to parse the files. If CPanel doesn’t issue the proper directives to Apache, then it won’t work.
I advise against parsing .html files as php, because you open a new territory for many mistakes, you need to remember to check all 3rd party files that have .html extension when uploading to the site in the future (to be sure they don’t contain any malicious code), make sure that any modules that allow uploading attachments, files, do not allow uploading .html files.