This is more a question of curiosity.
So I was reading a chapter from (Sitepoint’s latest PHP/MySQL book), in which the author mentioned using the extension “.html.php” to indicate files that has both HTML and PHP. I tried it out, and discovered this:
If I have a file “fileA.html.php”, and somewhere in “fileB.html” I have a link thusly:
<a href="fileA.html">Text text</a>
I’m able to link directly to fileA.html.php, correctly parsed, even though logic, and the book, tells me that I should have written href="fileA.html.php".
Anyone have any idea what PHP function does this, or if it’s just standard PHP behavior? (Not that I’m complaining, it’s just something my client noted and thought was cool.)
You’d have to have your server configured to do that. If you’re using Apache there are numerous ways to accomplish that with htaccess rewrite rules or other processors.
But if you’re going to go to those lengths, why require the html at all? I’d say either serve the file with the appropriate extension type (in that case just .php) or make it extensionless or extension-optional. The only reason to do it at all is to make it easier on your users. There’s no advantage for changing the extension otherwise.