Including Files (For Web layout)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Silent-Chaos
Forum Newbie
Posts: 6
Joined: Tue Oct 22, 2002 10:58 am

Including Files (For Web layout)

Post by Silent-Chaos »

Going to try and explain this the best I can, so please bear with me.

Ive got my site's layout saved as index.php Its the layout I want for my site, just minus the content in the bottom right corner where its supposed to be placed. Quite simply, I just wanted to be able to make content for my site, do an include so my layout is included with it, that way I only have to update one layout index.php file and the layouts for all the pages will be updated automatically. Guess my question is, how can I go about doing this? I know what I want to do, just not sure how to implement it.
f1nutter
Forum Contributor
Posts: 125
Joined: Wed Jun 05, 2002 12:08 pm
Location: London

Post by f1nutter »

You are going to need to use templates. HTML files which contain the layout with keywords which are replaced by a "template parser". For example,

header.html

Code: Select all

<html>
<head>
 <title>{TITLE}</title>
</head>
<body>
footer.html

Code: Select all

</body>
</html>

Code: Select all

<?php
include("header.html");

//content

include("footer.html");
?>
How good is your PHP / HTML? I find the best way to learn new techniques is to have a small working example. Download phpChat (http://www.phpwizard.net/projects/phpChat/) and have a look at the source code. There are enough pages to get the basic idea, but not too many so as to confuse you and scare you away! You won't need to get it working to see how it works! Good luck.
Post Reply