 Hey everybody this is Brian and welcome to the wow what video are we on that's right the 37th tutorial for lamp Wow, it's hard to believe we've done 37 of these PHP is really really grown with PHP 5 because they've added in object-oriented programming If you've been watching along we've been going over a lot of object-oriented programming or OOP or OOP as it's called My daughter calls it OOP. I don't know anybody else. It really does anyways Today we're going to be discussing class abstraction What's an abstraction? You ever have a daughter or a son or maybe a wife or a husband That's been gone for a while and they walk in the door and you go, where were you and they go? Well, I Went to this place and met these people and this thing happened and da-da-da, but they don't get real specific That's what abstraction is so we're going to make a abstract class And we're going to call it a person Now notice the keyword abstract What abstraction does is it allows us to actually define things without actually defining them so we'll say abstract and Abstract public function. Hello. Now. We can also Do a normal function Actually, I don't need to concatenate it Had a very long day at work you ever just have one of those days where you just want to you know Come home and I don't know punch a hole in the wall and kick the cat and all that stuff But you're not a violent person. So you just end up being lazy about it and don't do any of it It's kind of the day I've had All right, so we've got our abstract class here It's called a person and we have an abstract function see abstract public function. Say hello Now notice how it's a function and we even have a visibility modifier on it But the code block's missing instead. It's been replaced with this semi colon With an abstract class. You don't actually have to define anything. Now. Why would you want to do this? Now if you're making some sort of template like this is a person And if they say anything quote unquote, they want them to always say anything But we want the classes that derive from this class, you know classes that extend it to say hello differently So we'll say class employee And we need to actually extend We're going to extend the person class here now because this is an abstract class Notice how it says ain't fatal error one extract method one abstract method Must be declared meaning we have to implement this So what we do now is we just say We're not implementing that abstract function from the abstract class And then we can just say echo And what would an employee say yes master Almost actually make a manager And managers always say weird things like do my bidding So this is an abstract class. It's abstract because we have at least one abstract function It's abstract because we have not defined a code block. In other words, this is a great way of doing templates Now we have a employee class that extends person And we're implementing the say hello function And we also have a manager class that extends person and we're implementing the say hello function again But they do two totally different things Even though they come from the same class So that's a little bit of abstraction for you. Let me test this out a little bit by just saying, uh You'll see Call us for employee and then Man Yes, I forgot case sensitive here. Hello Like I said been one of those days There we go So we're going to have the employee say hello And then we're just going to have the manager say hello So as you can see they do two totally different things even though they extend the same class That's also called overloading, but we're not there yet. We'll get to that in a different tutorial So for this tutorial, you should just know what class abstraction is an abstract class is a class that has one or more Abstract functions, you know, it's abstract because it does not implement the code block. It just says here's a semicolon Semicolon keeps the compiler happy And then you extend that class and then you have to implement those abstract functions If you don't implement them bad things happen Compiler won't compile it and actually it's not even compiler with php. The interpreter won't interpret it in a thrown error Well, that's all for this tutorial. I hope you found this educational entertaining and thank you for watching