include() bottom with top

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
matt1234
Forum Commoner
Posts: 44
Joined: Wed Nov 26, 2008 9:43 pm

include() bottom with top

Post by matt1234 »

Is there a way so that I could put an include() at the top of each of my pages so that it will include a header and footer? Like this:

include("/file/blah/blah/directory/anotherdirectory/header.php");
which would include:
---------------------------
<div>
blah blah blah stuff
</div>

..

include("/blah/files/place/directory/footer.php");
---------------------------
So the header included file would have the top, have some sort of code (in this case, "..") which tells it to display whatever else from the page that's requesting the include(), and then after that, include the footer file data?
skullmunky
Forum Newbie
Posts: 12
Joined: Fri Apr 17, 2009 10:25 pm

Re: include() bottom with top

Post by skullmunky »

I don't think so ... if include is like include in C, it just writes everything in the included file directly in. when file A includes B, B has no way of knowing anything about A. So you'd have to include header.php and footer.php individually at the appropriate place in the file.
Post Reply