SHARE
TWEET

Untitled

a guest Jun 19th, 2017 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class Entity {
  4.    
  5.     private $type;
  6.    
  7.     public function __construct($type) {
  8.         $this->type = $type;
  9.     }
  10.    
  11.     public function getType() {
  12.         return $this->type;
  13.     }
  14. }
  15.  
  16. class Animal extends Entity {
  17.    
  18.     public function __construct($type) {
  19.         parent::__construct($type);
  20.     }
  21. }
  22.  
  23. class Dog extends Animal {
  24.    
  25.     private $tag;
  26.    
  27.     public function __construct($tag) {
  28.         parent::__construct("Dog");
  29.         $this->tag = $tag;
  30.     }
  31.    
  32.     public function getTag() {
  33.         return $this->tag;
  34.     }
  35. }
  36.  
  37. $dog = new Dog("Dog");
  38. echo $dog->getTag();
  39.  
  40. ?>
RAW Paste Data
Top