问题描述:

If someone could point out what I'm missing here, that would be appreciated

I'm new but I haven't encountered a situation where wrongly naming a html file as php can be bad.

Perhaps it's just less confusing for developers?

网友答案:

PHP files are sent to be evaluated after the browser requests them whereas HTML files are directly given to the browser.

So if there is no PHP code in your .php file, you are still sending it to be evaluated, though it doesn't do much to the loading time of the page, if anything.

网友答案:

If you've a web server that understands the .php file extension and has the necessary PHP module installed, there's no issue with simply renaming a .html file to .php (as long as all links to it are also renamed accordingly).

However there's absolutely no benefit in doing this (and I'd dispute any meaningful UX benefit from the user's perspective), as it'll mean that the web server will need to invoke the PHP module to parse the file. This will be a waste of time and memory, as it's just a plain HTML file.

相关阅读:
Top