Rather than type stuff out this explains https://stackoverflow.com/questions/2558559/what-is-abstract-class-in-php
In practice, what is abstraction?
I have read a lot about it but I don't get a practical explanation with PHP.
Abstraction is something more general than the thing you are talking about.
Let's say that you have a chair. Abstraction for that might be furniture.
Nothing more complicated than that. You can think of it as generalization.
Something you cannot initialized. You cannot create object from it. It's mainly used for inheritance
I have read about it and get two concepts, I would like to understand well.
- There is interface and abstract class.
- I read that the deficit of properties and methods is abstraction.
One concept applies to PHP and concept two applies to OOP.
There my confusion.
In your example, you could say OOP is the abstraction and PHP is the implementation ;-)
OOP is a concept and that can be implemented in multiple languages, but it has to conform to the concept of Classes/Methods/Inheritance etc. PHP implements these abstract concepts in a concrete way.
An abstract class specifically in PHP allows you to define some qualities that all classes derived from it will have.
Edit: importantly it doesn't say how you implement them, just that that all classes derived from it will inherit the abstract implementation by default.
It's worth looking into the discourse around the benefits of composition vs inheritance.
Please or to participate in this conversation.