Page 1 of 1

PHP files treated indivdually, or included?

Posted: Sun Apr 11, 2004 12:30 am
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.

Posted: Sun Apr 11, 2004 12:43 am
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. :-)