From the course: Learning the Standard PHP Library

Using the exercise files - PHP Tutorial

From the course: Learning the Standard PHP Library

Start my 1-month free trial

Using the exercise files

- If you're a subscriber to the Lynda.com library, you have access to the exercise files that I'll be using in this course. Download the zip file from the courses page, and extract them to somewhere convenient on your local computer. I've got them here on my desktop, so let's just take a look at them. There are no files for chapter one, but the files for the remaining chapters, are arranged in separate folders. If you open one of the dhapter folders, you'll see that some files are in pairs. For example, array.php and array_end.php. Array.php is what the file looks like at the beginning of the video in which it's used, and array_end.php is what it looks like at the end. When a file isn't one of a pair, for example, jason_decode.php, it usually means I started the exercise with a blank file, containing only an opening php tag. So this file contains the finished code. In one or two cases, single files contain fully worked examples for you to study. There's another folder called common, so let's just find that. And this contains three sub folders, data, documents, and images. And these will be used throughout the course. Because the php code needs to be passed by a web server, you'll need to copy the exercise files to a folder inside your testing server route. I've created a folder called SPL inside my server route, and I've copied the chapter folders and the common folder into it. So let's take a look at my set up in my code editor. For all the exercises, I'll be using the top level SPL folder as my working folder. Many exercises load data from two files in the common data folder, courses.jason and courses.xml. The information in both files is exactly the same. They contain details of php courses on Lynda.com, but in very different formats. The data is loaded using a relative file path. And to make it easier for you to view the finished files without needing to move them, the exercise files in the chapter folders, use the correct relative path from their current location. Let's just show you an example. Let's open chapter three and callback_filter.php. You can see her, that on line two, we're loading courses.xml, and the path begins with ../ because we need to go up one level from chapter three to be able to get into the common folder. But when I'm working on a copy of this file, in the top level folder, that ../ won't be there. So, if you find that external files aren't being loaded correctly, do check the relative path. So that's how the exercise files are organized. If you're ready, let's begin our exploration of the standard php library.

Contents