Jump to content

General HTML PHP structure question.

jlofft's Photo
Posted Jun 26 2012 07:06 PM
1733 Views

I am quite new to the web development world. I have just finished going through the O'Reilly PHP, Javascript, MySQL, and do have some experience with HTML.

My main question is how do you know whether the document type is supposed to be either .php or .html. Obviosuly I know what each is for but why not just have all the pages a .php extension and outputting the html when necessary. The way I am currently structuring my projects are a .html interface with a .php background that handles the user inputs, etc. However I know that in html documents they typically declare what type of html is being used (4.01, xml, etc.) in the DOCTYPE declaration.

Throughout the O'Reilly no documents used the DOCTYPE declaration and often just output the HTML using the END---END tags.

So my question is bascially, when is the DOCTYPE declaration needed, if at all, and is my website layout typical or is their a more optimal way to structure it.

Tags:
0 Subscribe


1 Reply

0
  nathanator11's Photo
Posted Jun 28 2012 08:08 AM

It's a good practice to put a DOCTYPE at the top of all of your pages.
The HTML5 DOCTYPE is short, so there's really no overhead in adding it:
<!DOCTYPE html>
.

As for the file extension: generally you should stick to .html unless the page is dynamic (or you expect to make it dynamic in the future).
If you do end up changing to .php, you can avoid breaking any links by using a .htaccess redirect.
--Nate