1 00:00:00,000 --> 00:00:00,460 2 00:00:00,460 --> 00:00:03,420 >> SPEAKER: Let's improve the course's homepage by factoring out some 3 00:00:03,420 --> 00:00:04,430 commonalities. 4 00:00:04,430 --> 00:00:08,660 In particular atop every one of my pages has been an HTML tag, a head 5 00:00:08,660 --> 00:00:11,070 tag, a title tag, and more. 6 00:00:11,070 --> 00:00:13,960 What if we instead put those tags in a separate file? 7 00:00:13,960 --> 00:00:19,200 In particular, what if we put those alone in a file called header.php? 8 00:00:19,200 --> 00:00:23,870 >> In header.php is just some HTML, precisely the HTML that used to be 9 00:00:23,870 --> 00:00:25,970 atop index.php. 10 00:00:25,970 --> 00:00:29,160 In footer.php, meanwhile, is the HTML that used to be at 11 00:00:29,160 --> 00:00:31,420 the bottom of index.php. 12 00:00:31,420 --> 00:00:35,470 How now to include this HTML inside of index.php? 13 00:00:35,470 --> 00:00:37,140 Well, let's take a look. 14 00:00:37,140 --> 00:00:42,260 >> At the very top of index.php, I can simply require header.php so that 15 00:00:42,260 --> 00:00:46,690 PHP's interpreter effectively copies and pastes the contents of header.php 16 00:00:46,690 --> 00:00:48,470 right there atop my file. 17 00:00:48,470 --> 00:00:53,350 Similarly, at the bottom of index.php, can I require footer.php. 18 00:00:53,350 --> 00:00:57,890 The only code now that's manually hard coded inside of index.php is the 19 00:00:57,890 --> 00:01:01,410 unordered list which, after all, changes from file to file. 20 00:01:01,410 --> 00:01:05,340 >> Indeed, if we now look at lectures.php, it similarly requires 21 00:01:05,340 --> 00:01:09,920 header.php and footer.php, but it has its own unordered list. 22 00:01:09,920 --> 00:01:14,720 week0.php has a very similar structure, but it instead has links to 23 00:01:14,720 --> 00:01:15,700 those PDFs. 24 00:01:15,700 --> 00:01:19,660 And week1, similarly, has links to its own PDFs. 25 00:01:19,660 --> 00:01:21,210 >> Now we've given up one feature. 26 00:01:21,210 --> 00:01:24,700 We've lost that h1 tag that specified a name for each file. 27 00:01:24,700 --> 00:01:26,460 But we'll bring that back before long. 28 00:01:26,460 --> 00:01:27,787