Help - Search - Members - Calendar
Full Version: PHP Template
Pixel2Life Forum > Help Section > PHP, ASP, MySQL, JavaScript and other Web/Database Programming Help
lol89
hi, how i can make simple php template so i need system where i have header and footer then i can change environment (home or what will be)
Demonslay
Well, this is quite a broad subject that a simple search can give you alot of tutorials on. Most people use frameworks that are built for using templates, such as a content management system (PHPBB and WordPress come to mind).

Here's a most basic 'technically' a template format.

header.php
CODE
<h1>I am the header, hear me roar!</h1>


footer.php
CODE
<p>I'm the footer, at the end of the page</p>


page.php
CODE
<?php include('header.php'); ?>
<p>This is my page, and I can alter it how I want. The header and footer are independent and can be altered separately, and will not have to be changed on every single page of the site!</p>
<?php include('footer.php'); ?>


page2.php
CODE
<?php include('header.php'); ?>
<p>See I'm a second page, and changing the header or footer will reflect a change on me too! You won't have to manually edit my header or footer on every page because you changed it from one location that I am pulling it from!</p>
<?php include('footer.php'); ?>


Basically that's all that really happens, but full on template systems have options for parsing certain tags and adding your own things to them. Take a look at PHPBB's template system and feel free to be amazed at its complexity. Or any forum software really.
lol89
thx man smile.gif
rc69
If you decide to develop something a little more complex than that, you should take a look around the p2l tutorials:
http://www.pixel2life.com/tutorials/php_co..._and_templates/
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.