Build a CMS Step 2
Organizing Sections of HTML
You may have noticed that the HTML code at the beginning and end of each page is exactly the same.
Instead of typing out all that code, we can use the PHP 'includes' command to do just that - include that code on each page.
If the HTML code for each of your pages was printed out on a piece of paper, you would take some scissors and cut it up into three parts - the 'main' section, and the parts above and below. On your computer, you will do the same thing with cut and paste. Each section will have its own file. The shared code before and after the 'main' sections can be called 'header.html' and 'footer.html'. Now, each page file will only contain the 'main' part.
Since we will be 'including' header.html and footer.html on our pages, we can save those two files in a new folder - 'inc', for 'includes'.
Example 1 - home.php
But... we can't use the '.html' exetension on our pages now - we need to use '.php' instead, to indicate that there is some PHP code inside the file, along with the HTML.