Calling the constructor of the parent class : Constructor « Class « PHP
- PHP
- Class
- Constructor
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);
}
}
?>
Related examples in the same category