Showing posts with label php programming. Show all posts
Showing posts with label php programming. Show all posts

Polymorphism in OOP

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;


Bookmark and Share

Difference between include and require in PHP?

What’s the difference between include and require in PHP?

require(): If the file is not found by require(), it will cause a fatal error and halt the execution of the script.
include(): If the file is not found by include(), a warning will be issued, but execution will continue.



Bookmark and Share