1 00:00:00,350 --> 00:00:01,600 Welcome back. 2 00:00:01,600 --> 00:00:04,220 We're ready to start building our media library. 3 00:00:04,220 --> 00:00:06,610 We're going to start by setting up a separate file for 4 00:00:06,610 --> 00:00:10,890 the header that we can include in all the pages of our library. 5 00:00:10,890 --> 00:00:13,340 This will make our site easier to maintain 6 00:00:13,340 --> 00:00:16,110 by giving us one place to update shared elements, 7 00:00:16,110 --> 00:00:20,760 like navigation links, instead of needing to update each page individually. 8 00:00:20,760 --> 00:00:23,810 Go ahead and launch the workspace that is on this page or 9 00:00:23,810 --> 00:00:25,770 download the project files to work locally. 10 00:00:26,910 --> 00:00:30,780 Most web servers, including the one in Workspaces, are configured to display 11 00:00:30,780 --> 00:00:37,050 a file named index.html or index.php as the main file by default. 12 00:00:37,050 --> 00:00:40,830 If you click the preview icon, a new window opens. 13 00:00:40,830 --> 00:00:43,070 In the index.html file is displayed. 14 00:00:44,150 --> 00:00:46,087 Go back to your workspace and open index.html. 15 00:00:46,087 --> 00:00:51,272 You can see that the file references an external style sheet here, 16 00:00:51,272 --> 00:00:58,820 and down on the content, we're referencing some external images for the suggestions. 17 00:00:58,820 --> 00:01:00,729 This page also has a number of links. 18 00:01:02,420 --> 00:01:03,710 Both here in the suggestions. 19 00:01:06,033 --> 00:01:08,060 And up here in the navigation. 20 00:01:08,060 --> 00:01:10,120 We haven't built these pages yet, but we will. 21 00:01:11,350 --> 00:01:14,570 Instead of actual links, you'll see hash signs as placeholders for now, 22 00:01:14,570 --> 00:01:18,190 and we'll update those links as we build out the pages. 23 00:01:18,190 --> 00:01:20,220 Before we start adding those new pages, 24 00:01:20,220 --> 00:01:23,030 let's explore how PHP files work on a server. 25 00:01:23,030 --> 00:01:26,999 Let's start by changing the title tag in the copyright date to use PHP. 26 00:01:26,999 --> 00:01:29,025 We'll start with a simple echo command. 27 00:01:29,025 --> 00:01:35,180 And we'll echo out the title as a string. 28 00:01:38,685 --> 00:01:40,560 This isn't actually very useful. 29 00:01:40,560 --> 00:01:44,066 But we'll be extending this in a later video to use a variable instead of 30 00:01:44,066 --> 00:01:44,598 a string. 31 00:01:44,598 --> 00:01:49,557 Using a variable for the title will allow us to use the same HTML on all the pages, 32 00:01:49,557 --> 00:01:53,370 but still have individual titles for each page. 33 00:01:53,370 --> 00:01:55,070 Now let's go to the footer and echo out the year. 34 00:01:59,649 --> 00:02:04,000 We'll use the built in function date with y for our year. 35 00:02:06,100 --> 00:02:07,840 Let's save this page and go back to the browser. 36 00:02:09,990 --> 00:02:11,580 When I refresh this page, 37 00:02:11,580 --> 00:02:14,600 we'll see something that you might not have expected to see. 38 00:02:14,600 --> 00:02:18,900 The PHP code here in the title tag, and nothing here for the date. 39 00:02:19,900 --> 00:02:23,590 Our Web server did not execute the PHP code in this file. 40 00:02:23,590 --> 00:02:24,710 Why not? 41 00:02:24,710 --> 00:02:28,030 Because our file has an extension of .html. 42 00:02:28,030 --> 00:02:32,540 Our server will only execute the PHP code in a PHP file. 43 00:02:32,540 --> 00:02:36,170 If that file has an extension, it identifies as PHP. 44 00:02:36,170 --> 00:02:38,417 This extension is usually .php. 45 00:02:38,417 --> 00:02:41,900 Let's go back to our workspaces and rename the index file. 46 00:02:43,690 --> 00:02:51,300 We'll rename this from index.html to index.php. 47 00:02:51,300 --> 00:02:55,210 Now when we preview this file in the browser, the Web server recognizes 48 00:02:55,210 --> 00:03:00,470 the extension, executes the PHP code and displays the title and the year correctly. 49 00:03:01,820 --> 00:03:04,795 So now we have the home page working as a PHP file. 50 00:03:04,795 --> 00:03:07,490 It's processing a little bit of code to handle the title and the header, 51 00:03:07,490 --> 00:03:08,680 and the date and the footer.