Exemple #1
0
    {
        // Call the Pet::play() method:
        parent::play();
        echo "<p>{$this->name} is fetching.</p>";
    }
}
// End of Dog class.
# ***** END OF CLASSES ***** #
// Create a dog:
$dog = new Dog('Satchel');
// Create a cat:
$cat = new Cat('Bucky');
// Create an unknown type of pet:
$pet = new Pet('Rob');
// Feed them:
$dog->eat();
$cat->eat();
$pet->eat();
// Nap time:
$dog->sleep();
$cat->sleep();
$pet->sleep();
// Have them play:
$dog->play();
$cat->play();
$pet->play();
// Delete the objects:
unset($dog, $cat, $pet);
?>
</body>
</html>