1 00:00:00,250 --> 00:00:04,670 In the last video, we saw that we could easily swap out our new child class, 2 00:00:04,670 --> 00:00:06,430 where we use the parent. 3 00:00:06,430 --> 00:00:08,710 Let's take a closer look at the result. 4 00:00:08,710 --> 00:00:12,386 Open index.php. We'll start by adding a var_dump of 5 00:00:12,386 --> 00:00:15,790 the listings within the foreach loop. 6 00:00:20,533 --> 00:00:22,110 Let's preview this in the browser. 7 00:00:25,300 --> 00:00:29,746 Lets view the page source, and increase the font size. 8 00:00:29,746 --> 00:00:36,944 This shows us that the object itself is a listing premium object, but 9 00:00:36,944 --> 00:00:42,790 its variables are taken from the listing basics class. 10 00:00:45,759 --> 00:00:48,966 Let's take a look at a couple more functions that will tell us about 11 00:00:48,966 --> 00:00:49,550 our class. 12 00:00:53,534 --> 00:00:59,189 Var_dump get_class, 13 00:01:03,296 --> 00:01:06,420 This will give us the name of the object's class. 14 00:01:06,420 --> 00:01:09,800 We can also check if this object is of a certain type. 15 00:01:09,800 --> 00:01:15,550 We'll do a var_dump is_a, pass the listing, 16 00:01:18,010 --> 00:01:22,070 And then the class we wish to compare, ListingBasic. 17 00:01:24,523 --> 00:01:26,020 Let's preview this again. 18 00:01:28,000 --> 00:01:32,351 Now we see that it tells us that our class is a listing premium, but 19 00:01:32,351 --> 00:01:36,330 our check with the is a function, returns true. 20 00:01:36,330 --> 00:01:41,015 That's because listing premium is a child, and therefore a type of 21 00:01:41,015 --> 00:01:46,090 ListingBasic, and can be used wherever ListingBasic is used. 22 00:01:46,090 --> 00:01:48,880 We could also see in the status of these listings, 23 00:01:48,880 --> 00:01:55,910 that some of them are premium, And some of them are basic. 24 00:01:55,910 --> 00:01:59,700 Let's go back to our collection class and use ListingBasic for 25 00:01:59,700 --> 00:02:03,800 our basic listings, and ListingPremium for our premium listings. 26 00:02:08,610 --> 00:02:12,240 In the addListing method, we need to check the status. 27 00:02:16,314 --> 00:02:19,940 If isset status, 28 00:02:23,690 --> 00:02:26,160 And that same status, 29 00:02:31,410 --> 00:02:38,508 Is equal to premium, then we're going to use ListingPremium. 30 00:02:38,508 --> 00:02:46,760 If not, else, we're going to use listingBasic. 31 00:02:51,409 --> 00:02:53,570 Let's check this out in the browser once more. 32 00:02:55,880 --> 00:03:00,810 Now the listings that have a status of basic, are of a ListingBasic class. 33 00:03:03,270 --> 00:03:08,050 And those that have a status of premium, are of a ListingPremium class. 34 00:03:08,050 --> 00:03:12,550 We're ready to actually extend our child class in more than just name