Define An Executive Class That Inherits Employee

<?php
   class Employee {
      private $name;      function setName($name) {
         if ($name == "") echo "Name cannot be blank!";
         else $this->name = $name;
      }      function getName() {
         return "My name is ".$this->name."<br />";
      }
   }
   class Executive extends Employee {
      function pillageCompany() {
         echo "I'm selling company assets to finance my yacht!";
      }
   }
   $exec = new Executive();
   $exec->setName("R");
   echo $exec->getName();
   $exec->pillageCompany();
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.