>> SPEAKER: Let's improve the course's homepage by factoring out some
commonalities.
In particular atop every one of my pages has been an HTML tag, a head
tag, a title tag, and more.
What if we instead put those tags in a separate file?
In particular, what if we put those alone in a file called header.php?
>> In header.php is just some HTML, precisely the HTML that used to be
atop index.php.
In footer.php, meanwhile, is the HTML that used to be at
the bottom of index.php.
How now to include this HTML inside of index.php?
Well, let's take a look.
>> At the very top of index.php, I can simply require header.php so that
PHP's interpreter effectively copies and pastes the contents of header.php
right there atop my file.
Similarly, at the bottom of index.php, can I require footer.php.
The only code now that's manually hard coded inside of index.php is the
unordered list which, after all, changes from file to file.
>> Indeed, if we now look at lectures.php, it similarly requires
header.php and footer.php, but it has its own unordered list.
week0.php has a very similar structure, but it instead has links to
those PDFs.
And week1, similarly, has links to its own PDFs.
>> Now we've given up one feature.
We've lost that h1 tag that specified a name for each file.
But we'll bring that back before long.