I'm in the process of building an eCommerce site for a college assignment. The question is, should all files be set up as .php? i.e. in what instance should or shouldn't be html? (Please note I've got the login and registration forms set up as .php which are currently connecting to a db). Many thanks.
Asked
Active
Viewed 81 times
0
-
It all depends on the requirements of the application, I've seen instances before where caches have created HTML files, and I've seen instances where HTML files have been used to hold content that is then used by multiple PHP scripts. I've also seen websites where every file is a PHP file, so this is like "asking how long is a piece of string?" – Professor of programming Apr 08 '15 at 11:10
-
I would recommend you make all your file .php. You should use a framework if it is allowed for the college assignment. It will help speed up your development – James Njuguna Apr 08 '15 at 11:10
-
There is no general rule for that. Both is possible and common. I prefer to keep it that way that I only use .php if it's necessary. Means: no php code in a file -> use html. – MichaelS Apr 08 '15 at 11:14
-
Totally get your points. Perhaps the "safest" approach is to simply set up all files as ".php". thanks a lot. – Martin Apr 08 '15 at 11:15
1 Answers
0
I personally recommend you use .php files only for your website. In general .html files are used for templating and they only set up the 'view' of the page. By default, .html web pages can not use PHP code unless you set up the server to do so (For example using a .htaccess file as explained here)
It's really just as Bonner said, asking how long is a piece of string. The answer can differ depending on what you are doing. Based on what you are working on I still recommend you use .php as the file extension for your project.

Community
- 1
- 1

Rizky Fakkel
- 8,703
- 1
- 14
- 20