inherit.php

Source of inherit.php

<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>inherit.php</title>
</head>
<body>
  <?php
    require_once("Critter.php");
    
    class BitterCritter extends Critter{
    
      //all properties and methods inherited from Critter
      
      //You can add new properties and methods
      public function glower(){
        return "$this->name glowers at you without saying anything."; 
      } // end glower
      
      //if you over-write an existing method, the behavior changes
      public function talk(){
        return "None of your business!";
      } // end talk
    
    } // end class def
    
    $a = new BitterCritter();
    
    print $a->glower() . "<br />";
    print $a->talk() . "<br />";
    
  ?>
</body>
</html>