14: Abstract Classes in OOP PHP | Abstract Explained | Object Oriented PHP Tutorial | PHP Tutorial

preview_player
Показать описание
In this OOP PHP tutorial, I will let you know about abstract classes in OOP PHP. Abstract classes in PHP are used to help us create behavior similarly to interfaces, but they do serve a different purpose as well.

➤ MEET OTHER AWESOME PEOPLE!

FollowAndrew
With over 20 years experience, Andrew is creating web & front-end design tutorial videos!

➤ GET ACCESS TO MY LESSON MATERIAL HERE!

First of all, thank you for all the support you have given me!

I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!

I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.

I hope you will find it helpful :)

Рекомендации по теме
Комментарии
Автор

I love Dani's tuts because he speaks a neutral dialect of English (so many computer tuts come out of India and the people speaking have a very poor grasp of English and they are too difficult to uunderstand) and he gives very helpful info. Dani is one of the best channels on youtube for programming!

stormybear
Автор

I'm going to leave this here in case someone finds the use of abstract classes confusing even after the explanation.

Consider an abstract class for an Employee. Each employee is going to have common attributes such as first name, last name, address and so on, but there will be some attributes that differ.

Now, let's say we are talking about an educational institution. There can be "permanent" or "visiting" employees. Permanent employees get paid an equal amount every month, so their salaries can be defined in their own "PermanentEmployee" class which extends the main "Employee" class. And for visiting employees, the salary can be defined in a class called "VisitingEmployee" which also extends the main Employee class.

abstract class Employee{
protected $firstName;
protected $secondName;
protected $address;
}

class PermanentEmployee extends Employee{
private $salary;
}

class VisitingEmployee extends Employee{
private $hourlySalaryRate;
}

In this way, we get to use the common attributes through the child class, as well as attributes of their own.

MuhammadAli-vemt
Автор

I would love to see a OOP PHP full site video after the oop tutorial. My morning starts with a coffe and lesson here. Keep it going.

davidsimonovic
Автор

If you're wondering what abstract classes are (like me), and WHY we use abstract classes, go to 8:41. I've been looking up and down the internet for someone to explain this in simple words to me, and finally found it. For some reason the other people I stumbled upon all make it unnecessarily overly complex. Especially if they intend to teach this to beginners.

onee
Автор

Always wandered what the Peaky Blinders are up to these days..

andreitodosi
Автор

Deep Theory + Practical Life Examples + Clear Explantations = Dani :)

wadiibounenni
Автор

I just discovered that the order in which classes are included is important. I haven't heard you mention that yet. It took me a few minutes to figure out why I was getting an error, as I had been using a separate header, index, footer page. After reducing it down to what you have here, I still got an error stating that the "Visa class could not be found referenced in BuyProduct". Then I moved the include abstract statement to the top, and voila! It works.

bgray
Автор

Finally a clear explanation of abstract classes

alexlytle
Автор

I think by just listening your explanation like a podcast i will understand what is abstract class is, very clear, thank you

binsarharseno
Автор

I've watched both your PHP playlists and followed every step - it's really helped me understand PHP on a better level than sites like Codecademy thanks bud!

jaicarter
Автор

Some important rules:

1. One class can extend only one abstract class (PHP doesn’t support multiple inheritance).
2. Any class with at least one abstract method must be declared abstract.
3. Abstract classes might contain concrete methods (rules or logic already implemented), interfaces don't have any implementation (it is just a prototype declaring the signatures of the methods - return type, parameters), it's just a contract that must be followed by implementing classes which will supply its own implementation.

LostAlienOnEarth
Автор

One other thing that you can do in extending class is you can play the callback like in BuyProduct Class
public function visaPayment(){
$callback = parent::visaPayment();
$callback.= " from buy product."
return $callback;
}

output will be "Perform a payment from buy product."

earlempic
Автор

Wow 3 days of school = 1 of your videos, (i need to put more attention to class) but i learn better here.

asuUcKa
Автор

Dani for a person whose first language is not English, you have really a masterful command of the language. Your accent sounds very natural, i think you must've spent a lot of time in the USA to master our crazy accents. I was an ESL teacher for many years and I wish I could bottle your accent and give it to my students. How long were you in the USA and what part of the country? I'm guessing the midwest or California.

stormybear
Автор

the best oop php tutorial I've come across. Clarity!!!!

SherwinlouwZa
Автор

Started watching your videos to learn a few concepts that i was uncertain of. And now im watching all the videos just because I love they way you speak😂😂❤️
But I must appreciate, the explanation is convincing, they way you present the content is awesome. Good luck❤️

m_lk
Автор

I'm here! 😎 Great video, just posting a comment to show some support! Keep up the good work. 🤙

BornDoubleUp
Автор

Just like the interfaces video, this is great! Clear explanation with real world use case. Thank you!

lpanebr
Автор

Thank you for the effort that you put in making these videos. Your way of clarifying things makes this way easier.

dzintarsmagons
Автор

this course is amazing, amazing teacher. And also its a strange feelin to learn all of this from Ellon Musk. HAHAHA just kidding, thank you a lot for all of this classes. Really helped. The world need people like you!

MatheusBellucio
visit shbcf.ru