Mega Code Archive

 
Categories / Php / Class
 

Using the parent construct

<?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(  ) {     }     function eat(  ) {         parent::eat(  );         $this->meow(  );     } } ?>