Mega Code Archive

 
Categories / Php / Class
 

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);     } } ?>