In this repo, you will find 4 simple code examples about Abstraction, Inheritance, Polymorphism and Encapsulation.
Abstract classes and methods are when the parent class has a named method, but need its child class(es) to fill out the tasks. An abstract class is a class that contains at least one abstract method. An abstract method is a method that is declared, but not implemented in the code.
Inheritance in OOP = When a class derives from another class. The child class will inherit all the public and protected properties and methods from the parent class. In addition, it can have its own properties and methods.
Polymorphism allows objects of different classes to respond differently based on the same message. To implement polymorphism in PHP, you can use either abstract classes or interfaces. Polymorphism helps you create a generic framework that takes the different object types that share the same interface.
Encapsulation in PHP means, enclosing the internal details of the object to protect from external sources. It describes, combining the class, data variables and member functions that work on data together within a single unit to form an object. Otherwise, its the bundling of properties and behavior in a single class unit.