Polymorphism

Polymorphism is a Greek word. Polymorphism is created by two different words poly (means many) and morph (means forms).

It is another functionality of OOPS. In programming language two types of Polymorphism are there.

  1. Function overriding (Run time Polymorphism)
  2. Function Overloading(Compile time Polymorphism)-  PHP function overloading is not supported yet.

Function Overriding:

Overriding is happened only in child class.

If parent class declares a function and child class wants to override parent class function then function overriding means run time polymorphism happened.

Example