2 replies [Last post]
Last seen: 12 years 50 weeks ago
Joined: 2004-07-06
Posts: 20
Points: 0

Hello. I am trying to learn how to build templates using php.

<div id="footer">
include ('footer.html')

Should I put the the <head> info, including the doctype and title in a seperate file and include it?

Also if I have these includes throughout my site, won't most of my pages be .php pages?

If anyone knows of good tutorials or discussions about this subject please tell me, because I can't find any.


roytheboy's picture
North Wales, UK
Last seen: 7 years 19 weeks ago
North Wales, UK
Timezone: GMT+1
Joined: 2004-09-18
Posts: 2233
Points: 41

Need help learning how to build templates.

Hi Matt,

WRT the <head> info: You can do, it's up to you, but as you are probably new to php and are not yet actively scripting content, there's probably no need. As you learn about php, so you'll see what you can and can't do with it, and then you'll be able to answer your own question.

WRT .php pages: you can include() any type of page that you like (within reason), but unless you reconfigure your webserver or htaccess files from their default settings, you need to suffix pages with active php scripts as .php (I'm generalising here so as not to swamp you with information). If footer.html is a static page with no scripts then it can stay as footer.html.

WRT tutorials: In my early days of scripting I wasted a lot of time by NOT following tutorials or books. I picked it all up piecemeal so I only know the php manual (which will become your bible). However; this looks okay to start with > http://academ.hvcc.edu/~kantopet/php/index.php

Good luck - it's a great scripting language Smile

Life's a b*tch and then you die!

prince's picture
Last seen: 11 years 46 weeks ago
Joined: 2004-10-11
Posts: 4
Points: 0

One example

Example using php includes to make a template: