Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.php with HTML versus .html with PHP

Tags:

html

php

When I am starting to build a site that is going to require both HTML and PHP, should I be making a .html file with PHP in it (as in the file would be, say, index.html but within it there would be various tags)? Or, should I be making the files .php files and simply include HTML within it (as in the file would be, again say, index.php and it would start as PHP and I would simply intertwine HTML)?

TL;DR: Should I be weaving HTML into .php files or weaving PHP into .html files?

like image 686
devirkahan Avatar asked Jan 28 '13 22:01

devirkahan


2 Answers

It should be a PHP file with HTML "weaved" into it. By default if your server sees an HTML file it does not think it needs to process scripts on the page and will render it. If it sees a PHP extension, it knows it needs to run through the PHP Processor.

You can modify your htaccess to allow HTML to be rendered through the processor, but there really is no need for you to be modding that, especially if you are a beginner.

like image 107
Daniel Beacham Avatar answered Sep 22 '22 01:09

Daniel Beacham


You use PHP files with HTML in it

like image 40
Paul Dessert Avatar answered Sep 25 '22 01:09

Paul Dessert