- Output for 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
- Salary: 3000 Salary: 7000
<?php
class Employee
{
protected $salary;
public function __construct($salary)
{
$this->salary = $salary;
}
public function getSalary()
{
return $this->salary;
}
}
class Manager extends Employee
{
protected $bonus;
public function __construct($salary, $bonus)
{
parent::__construct($salary);
$this->bonus = $bonus;
}
public function getSalary()
{
return $this->salary + $this->bonus;
}
}
function printEmployeeSalary(Employee $employee)
{
echo "Salary: " . $employee->getSalary() . "\n";
}
$employee = new Employee(3000);
$manager = new Manager(5000, 2000);
printEmployeeSalary($employee); // Ожидается: Salary: 3000
printEmployeeSalary($manager); // Ожидается: Salary: 7000