Page 1 of 1

include() bottom with top

Posted: Mon Apr 13, 2009 8:10 pm
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?

Re: include() bottom with top

Posted: Fri Apr 17, 2009 11:38 pm
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.