By 24/02/2016 3 Comments

What Is Inheritance In PHP Classes?

  • When one class is extended in another class that relationship is called Inheritance.
  • Inheritance is one of the most popular principal of object oriented programming.
  • This relationship is called parent child relationship between classes.
  • When one class is inherited to other class its all public and protected members (functions) and (properties) are also inherited in that class.
  • The extends keyword is used to inherits one class to other.


 // parent class.
 class Class_Asp{
 public $Typing;
 public $Feature;
 public $Name;
 function __construct($name){
 $this -> Name = $name;
 public function get_typing(){
 return "It has " . $this -> Typing;
 public function get_feature(){
 return "It is " . $this -> Feature;
 public function get_name(){
 return $this -> Name;
 // parent class is being inherited in its child class.
 class Class_Asp_Mvc extends Class_Asp{
 public $Scope;
 function __construct($name){
 $this -> Name = $name;
 public function get_scope(){
 return "It's Scope is " . $this -> Scope;
 // child and parent class object creation.
 $class_asp = new Class_Asp("Asp.NET");
 $class_asp_mvc = new Class_Asp_Mvc("MVC");
 $class_asp_mvc -> Typing = "Strong typing.";
 $class_asp_mvc -> Feature = "Secure, object oriented and robust.";
 $class_asp_mvc -> Scope = "High.";
 echo $class_asp_mvc -> get_name() . " extends " . $class_asp -> get_Name() . "<br>";
 echo $class_asp_mvc -> get_typing() . "<br>";
 echo $class_asp_mvc -> get_feature() . "<br>";
 echo $class_asp_mvc -> get_scope();

Posted in: PHP, Solutions

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .