Polymorphism in OOP:


In this tutorial we will study about polymorphism.
  • Polymorphism in PHP5 : To allow a class member to perform diffrent tasks.
  • polymorphism where the function to be called is detected based on the class object calling it at runtime.

Example:
< ?
class Person
{
    public function Talk()
    {
         echo "English";
    }
}

class Language extends Person
{
      public function Talk()
      {
           echo "French";
      }


}

function CallMethod(Person $p)
{
      $p->Talk();
}



$l = new Language();
CallMethod($l);
?>


Output:
French;