Calling The Constructor Of The Parent Class

<?php
    class Cat {
    var $age;    function Cat($new_age){
        $this->age = $new_age;
    }
    function Birthday(  ){
        $this->age++;
    }
    function Eat(  ){
        echo "Chomp chomp.";
    }
    function Meow(  ){        echo "Meow.";
    }
}
class MyCat extends Cat {
    function MyCat($new_age) {
        parent::Cat($new_age);
    }
}
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.