Simple PHP template
Have you ever wondered how to create a simple PHP template for using on your web site? This tutorial will explain the concept and in the end you will see some code examples. The concept of templates is that from one simple index file we include some other file based on GET variables. If you don’t know what a GET variable is this tutorial may be over your head and I suggest you learn this otherwise.
The advantage of using templates are:
- Easy to maintain
- Easy to change design
- Consistent look
Here are the simplified code for index.php
// Code for including css file
...
// Code for menu etc.
All you need to do now is create the individual pages. If you want additional pages all you have to do is create a link in the menu and make an include statement in the switch block. The pages should only contain text and/or html, all the styling should be in a css file included in the index file.
This is a great site for PHP help. Thank you so much for the content is not priceable! This will help me a ton
Tanks
Pity this doesn’t work!
try to add break statement…then this example will be more functional.
Horny cam girls, free live video chat…
…
this does work, works like a charm. the only thing is it needs you to add one thing to the code: after every case ‘blah’: include(“blah.inc”); statement you need to add a break; statement to stop all of your included files appearing at once.
once i added that i found that this little wedge of code does pretty much everything i was hoping. might need to investigate possible abuses of the $_GET variable but they’re probably quite easy to resolve.
good job whoever came up with this
jack