using "php includes" to update my website?help!?

daisyflower_x

New member
I have a website which is planning to have loads of pages and i wouldnt have the time to update all the pages with new links but was told i could do this easily with php.includes.
Ive looked it up and i dont really understand how to work it.
Ive got the code and everything i just dont know what to put the filename as AND where to put the code?
thank you
xoxo
 
Here's how it normally works... Let's say you have some content that you want to appear at the top of every page on your site. Put this content in a file called head.php. If you have content that you want to appear at the bottom of every page on your site, put this content in a file called foot.php.

Then, you include head.php near the top of every page, and foot.php at the bottom of every page. The code to include head.php would be:
<? include("head.php"); ?>

just, put this line near the top of every page on your site that you want the content in head.php to appear on.

This way, if you ever need to make a change to the content that's at the top of each page, you only need to change it once (in head.php).
 
You can use PHP include() in many ways to make your website easier to maintain. Some examples of include() are:

Navbar - You can update links for your whole website by just changing one file using include(); this is how.
1. Make a section in your html file where you want the navbar. (using divs)
2. Put <? include($_SERVER["DOCUMENT_ROOT"] . "/navbar.php") ?>
3. make "navbar.php" in your root folder.
4. In "navbar.php" put: "<a href="/">Home</a>" etc...

Hope this helps you get the idea.
 
Back
Top