Code
<?php
class Person {
public $name;
public $age;
public function __construct($name, $age) {
$this -> name = $name;
$this -> age = $age;
}
public function introduce() {
echo "My name is {$this -> name}. My age is {$this -> age}";
}
}
class Tom extends Person {
public $school;
// overriden method
public function __construct($name, $age, $school) {
$this -> name = $name;
$this -> age = $age;
$this -> school = $school;
}
public function introduce() {
echo "My name is {$this -> name}. My age is {$this -> age}. My school is {$this -> school}";
}
}
$tom = new Tom('Tom', 29, 'Foothill School');
$tom -> introduce();