ep11_oop_inheritance.php
<?php
class Animals {
protected $name;
protected $breed;
public function __construct($name, $breed)
{
$this->name = $name;
$this->breed = $breed;
}
public function getMeNameOfAnimal(){
return "The name of animal is : $this->name";
}
public function generalName(){
return "I am an animal";
}
}
class Dog extends Animals{
public function getMeBreedOfAnimal(){
return "The breed of animal is : $this->breed";
}
public function generalName(){
return "I am a Dog";
}
}
$dogOne = new Dog("Maggie" , "Pug" );
Output
Output for this tutorial goes here.
The name of animal is : Maggie
The breed of animal is : Pug
I am a Dog