Beispiel #1
0
// End of Cat class.
/* Dog class extends Pet.
 * Dog has additional method: fetch().
 */
class Dog extends Pet
{
    function fetch()
    {
        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');
// Feed them:
$dog->eat();
$cat->eat();
// Nap time:
$dog->sleep();
$cat->sleep();
// Do animal-specific thing:
$dog->fetch();
$cat->climb();
// Delete the objects:
unset($dog, $cat);
?>
</body>
</html>