OOP in PHP
Object is instance of class, to use methods and variable of class out side the class.
There are 3 types of visibility to control methos and variable in php.
- Using inheritance you can access property or methods of one class to another class.
- In PHP multilevel inheritance is possible but multiple inheritance is not possible. In simplified terms in php child class can not inherit more than one parent class.
- But hierarchical inheritance possible, parent access grand parent property and grand child access property of parent class.
- Interface same as abstract class, we can't create object of interface class but we implement interface class to another class.
- All methods declared in an interface must be public, this is the nature of an interface. To implement an interface, the implements operator is used.
- Interface class method are define only but it declare out side class where it implement.
- Interface support multiple inheritance