[thelist] Including file using $page

Stephen Rider evolt_org at striderweb.com
Sun Aug 31 16:19:19 CDT 2008

I would do the inverse of what you're doing -- have separate pages and  
call the same header/footer each time:

<?php include ("header.php"); ?>
content content content
<?php include ("sidebar.php"); ?>
<?php include ("footer.php"); ?>

This is basically what WordPress templates do, and it works very  
well.  Break the page up into pieces, and call the pieces as you need  


On Aug 30, 2008, at 6:14 PM, Rae wrote:

> I'm guessing this is a really easy question for everyone out there but
> it seems to have me really stumped.  If I knew what words to use I  
> could
> google it but the combinations I'm using keep telling me the same old
> thing.  I'd like to have my main index.php page, in the middle of that
> is where the content will go based on the page the person is viewing.
> Such as:
> <<Header, Menu, etc>>
> <?php include ("pages/$page.php"); ?>
> <<Footer, etc>>
> How do I define $page so that it pulls the appropriate page from  
> within
> my pages/ directory.  I've seen the outcome used in the url such as:
> http://www.somesite.com/index.php?page=somepage
> And is this the best way to achieve this?  Any help is appreciated!

More information about the thelist mailing list