PHP files treated indivdually, or included?

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
Aleister
Forum Newbie
Posts: 20
Joined: Wed Apr 07, 2004 5:43 pm

PHP files treated indivdually, or included?

Post by Aleister »

This sort of goes along with a post I just had, but I wanted to hear some opinions on something specific.

I can either have each one of my pages like this :

Code: Select all

<?php require_once 'header.php'; ?>
<p>this is the content in index.php</p>
<?php require_once 'footer.php'; ?>
which would mean true paths (in links) to all my files... or I could use a variable, and just pass index.php the file I want.. and use this:

Code: Select all

<?php require_once 'header.php'; ?>
<?php require_once '$x.php'; ?>
<?php require_once 'footer.php'; ?>
where x is like this: index.php?x=whatever

Any thoughts? I can't really think of any advantages/disadvantages either way.. but I am very new to PHP. Thanks.
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

Post by William »

Well, I ussaly make header, footer, Navigation, (If tehre is a section on right that to). Then the main content is stored in a folder called pages. Then I just use switch statements to include files like ?p=home. It would include pages/index.php .ect, For main page. I always thaugth it looked cleaner. And then the like navi.php, footer.php, header.php, Would be put into a folder called inc. :-)
Post Reply