Vote Up 0 Vote Down

What is the use of Inheritance in PHP ?

What is called Inheritance ? What is the same thing in procedural programming approach ? Please provide an
example.
flag

Answers


Vote Up 0 Vote Down
Inheritance in PHP helps reusing of the code. Inheritance is like including a library in the procedural programming.
But more options and features exists in Inheritance compared to simply including a library. We can build a Login class
in one project and reuse that class in another project.

In theoritical example consider we have a Bird class. Suppose we are building another class called Parrot we can
reuse the functions of the Bird class because Parrot is a Bird and Bird has the common functions of all birds like
flying, eating etc. Here we call the Parrot class as the child class and the Bird class as the parent class.
flag | link |

Your Answer

Login before answering

Login with facebook