Using The Extends Keyword To Define A Subclass

<?php
class Cat {
    var $age;    function Cat($new_age){
        $this->age = $new_age;
    }
    function Birthday(  ){        $this->age++;
    }
}
class MyCat extends Cat {
    function MyCat(  ) {
    }
    function sleep(  ) {
        echo("Zzzzzz.<br />");
    }
}
$fluffy=new MyCat(  );
$fluffy->Birthday(  );
$fluffy->sleep(  );
echo "Age is $fluffy->age <br />";
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.