Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert/Include/Imbed PHP files in other PHP files

Status
Not open for further replies.

TheFoxy

Programmer
Nov 22, 2002
48
GB
Hey,

Say I have a PHP script (with some plain HTML in it too) that creates a navigation bar, and one that creates a footer. How would I go about 'including' these seperate pages/scripts into my content pages? (They would be PHP or plain HTML). I mean rather like an M$ Frontpage (yes I used to use that...) Include Page component.
 
That simple? Lol, thanks! That will be very useful.
 
you can also use require('page.ext'), which I believe stops execution if the page is not found, whereas include() jsut gives an error message and tries to keep going.
 
How does the inserted page behave? E.g., will it follow it's own style layed out in the header or use the one on the main page?
 
If you mean what stylesheet attributes it will use, then it should use those defined in the main document.

Think of the included file as simply a snippet text that becomes part of your code rather than as a page in itself.
 
Think of it as the contents of the other page just being inserted into the current page, it is treated as part of that page (has access to all the variables etc).
 
So, the HTML header in the included file is ignored, basically?

Also, does the main page has access to PHP variables, etc from the included page?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top