Header and Footer Snippets

Let's curtail the duplication of code by moving common HTML code into separate files.

Creating separate files for common HTML code

Along the way, you may have noticed some duplication in the code we copied and pasted in several places. For starters, we have been duplicating most of the basic HTML structure (<!DOCTYPE html><html...) every time we create a new page. What’s inside <body>...</body> will be different for every page, but the rest of the HTML can be included from a shared snippet. Let’s start by moving the common HTML code out of login.php into reusable snippets.

Get hands-on with 1200+ tech skills courses.