<?php
class Person {
private $name;
private $age;
public function __construct($name, $age) {
$this->name = $name;
$this->age = $age;
}
public function getName() {
return $this->name;
}
public function getAge() {
return $this->age;
}
}
class Employee extends Person {
private $employeeId;
public function __construct($name, $age, $employeeId) {
parent::__construct($name, $age);
$this->employeeId = $employeeId;
}
public function getEmployeeId() {
return $this->employeeId;
}
}
class Manager extends Employee {
private $department;
public function __construct($name, $age, $employeeId, $department) {
parent::__construct($name, $age, $employeeId);
$this->department = $department;
}
public function getDepartment() {
return $this->department;
}
}
// Create an instance of Manager
$manager = new Manager('John Doe', 35, 'EMP001', 'Sales');
// Access methods from Person class
echo $manager->getName() . '<br>';
echo $manager->getAge() . '<br>';
// Access methods from Employee class
echo $manager->getEmployeeId() . '<br>';
// Access methods from Manager class
echo $manager->getDepartment() . '<br>';
?>