Multilevel and Multiple Inheritance in PHP – onlinecode
onlinecode
Multilevel and Multiple Inheritance in PHP – onlinecode
In this post we will give you information about Multilevel and Multiple Inheritance in PHP – onlinecode. Hear we will give you detail about Multilevel and Multiple Inheritance in PHP – onlinecodeAnd how to use it also give you demo for it if it is necessary.
Multilevel and Multiple Inheritance in PHP :
PHP OOP does not allow multiple inheritance, it allow only multilevel inheritance.
In simple word, subclass can not extend more than one super class. But PHP allow hierarchical inheritance, Hierarchical inheritance means child can get property of their parent and parent can get property of grand parent, so in this way child can get also some property of their grand parent.
class demo{//Your class body}class demo1{//Your class body}class demo3 extends demo1 demo2{//your class body}
Above code will not work in php because php does not allow multiple inheritance.
Best example of multilevel inheritance in PHP
class grandParent
{
//Body of grand parent class
}
class parent extends grandParent
{
//Body Of parent class
}
class child extends parent
{
//Body of child class
}
class grandParent{//Body of grand parent class}class parent extends grandParent{//Body Of parent class}class child extends parent{//Body of child class}
Above example is so clear to understand, child class is extending parent class and parent class is extending grand parent.This was a very basic example to understand the concept of multilevel inheritance in php oops.
Note : only Interfaces support multiple inheritance
Label :
PHP
OOP
Object Oriented Programming
Hope this code and post will helped you for implement Multilevel and Multiple Inheritance in PHP – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs