This tutorial will teach you all about PHP includes. This is very helpful if you have multiple pages. You can use PHP includes
for changing layouts with ease, or making a small change that applies to all pages. Now let us commence! =)
PHP Includes Tutorial
1. Open up 2 new text documents. Name one header.php and the other footer.php. You must remember to add the extension .php or
it won't work.
2. Open up your index page and copy everything up to your content and paste it all in header.php. That means even your
div positioning right before the content. This means all this stuff will be the same for every page of your site. Save.
3. Do the same to your footer.php, except put all your ending tags in there, such as </div>, </body>, and </html> only. Save.
4. So now your index page should only have your content, and nothing else. Now to the includes. So you have your
3 pages, index, header, and footer. In your index page, on top of your content add this:
Change "user" to the username. If you're hosted on a domain, ask your host for the username. Change "folder" to the
folder that you keep all your files. Usually it would be your own username.
making the same changes as the header. Paste this at the very end of your document, which would be after all your content.
6. Do steps 2-5 to all your pages, changing the extension to .php if your extensions are .html. After all your pages have been
changed, upload everything, including the header and footer. Now, when you want to change your layout or make a change, go to header.php and change it there. It
will apply to all your pages. And if you look at your source code, it still says the whole code without the PHP.
Final Note
I hope this tutorial helped you lots! I worked hard writing this tutorial, so I would appreciate it if you
provided a link back to me if it helped you in any way. If you have
any questions about this tutorial, don't hesitiate to email me.