Aleks
asked on
PHP - use includes for header, body and footer
I am new to PHP and bootstrap, but I managed to create a page that has a top navigation bar, such as the one on this page (logo and nav bar), then the body and at the bottom the footer. But right now this "page1.php" has all the code.
I am about to start doing many pages and I don't want to repeat this code on every page, I just want to add an 'include', so that when I do add that line of code then it calls the page and displays the top and bottom besides whatever code I have on the page.
What would the code be for that ?
"page1.php" would be the body
"top.php" would be the header and navigation bar
"footer.php" would be the footer.
If I take the code out of 'page1.php' and put it into 'top.php' and 'footer.php' ... what code would I need to add to 'page1/php' to call for the other two pages and for page1.php to know that they go at the top and bottom of the page.
I hope I explained myself properly.
I am about to start doing many pages and I don't want to repeat this code on every page, I just want to add an 'include', so that when I do add that line of code then it calls the page and displays the top and bottom besides whatever code I have on the page.
What would the code be for that ?
"page1.php" would be the body
"top.php" would be the header and navigation bar
"footer.php" would be the footer.
If I take the code out of 'page1.php' and put it into 'top.php' and 'footer.php' ... what code would I need to add to 'page1/php' to call for the other two pages and for page1.php to know that they go at the top and bottom of the page.
I hope I explained myself properly.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Never mind. I realized that wherever I place the code that is where the include is added :)
ASKER
Thanks !
Yes, the code runs top-to-bottom unless control structures change the logic flow. Thanks for the points and thanks for using E-E, ~Ray
ASKER
Thank you ! I am just starting with PHP seems pretty straight forwards. I am also using some DW extensions for faster development, so far I have used it with bootstrap and looks great ! And you are welcome.
ASKER