PHP includes is an important part of PHP. In this tutorial, you will learn how to use PHP includes. If you are using HTML, it may be very annoying to have to change every single page for one layout everytime. PHP includes lets you change two pages only, and change the layout for your whole site. Cool ehe? Read on! LINK BACK and credit! (I numbered the tutorial so you will remember which step you were on!)
You will need a notepad or editor of some sort, and a host that will host php files.
1. Here is what a basic HTML page looks life. Annoying, right? (Your stylesheet may be different, but it's okay.)
Your page title
Main content here
2. You take the header part which is always the same which each page, then put it in your notepad and name it header.php. (again, yours might be different.) Your page title
3. In a new file named footer.php, take the bottom part of your HTML that is the same with every page, and paste it into your notepad.
4. So now you're left with the body part of your stylesheet, and it should change with each page. Join it together, and it looks like this:
<?php include("header.php"); ?>
Main content here
<?php include("footer.php"); ?>
5. Every time you make new pages, you will need <?php include("header.php"); ?> and
<?php include("footer.php"); ?> The files also need to end in .php!