Showing posts with label inheritance. Show all posts
Showing posts with label inheritance. Show all posts

Friday 20 June 2014

What is inheritance PHP ?


What is inheritance?

By inheritance a class, we create a new class with all functionality of that existing class, and we can add new members to the new class. This way we can extend existing class without modifying its code.

When we inherit one class from another we say that inherited class is a subclass because it is created from another class.

class person{
var $name;
 function printpersonInfo()
  {
    echo $this->name;
  }

}

class employedPerson extends person{
 var $occupation;
 function printpersonInfo()
 {
   patent::printpersonInfo();
 }