<?php
class employee {
// Properties
public $name;
public $salary = 0;
// Methods
function set_name($name) {
$this->name = $name;
}
function get_name() {
return $this->name;
}
function set_salary($salary) {
$this->salary = $salary;
}
function get_salary() {
return $this->salary;
}
function populate()
{
$worker = array();
$worker[0] = new employee();
$worker[0]->set_name('Linda');
$worker[0]->set_salary(5800);
$worker[1] = new employee();
$worker[1]->set_name('Manuel');
$worker[1]->set_salary(2750);
$worker[2] = new employee();
$worker[2]->set_name('Luis');
$worker[2]->set_salary(3200);
$worker[3] = new employee();
$worker[3]->set_name('Carly');
$worker[3]->set_salary(2999);
$i = 0;
}
function checkTaxes()
{
while ($i < 4)
{
echo "Name: " . $worker[$i]->get_name();
echo " - Salary: " . $worker[$i]->get_salary();
if ($worker[$i]->get_salary() >= 3000)
{
echo " - You have to pay taxes!<br><br>";
}
else
{
echo " - You don't have to pay taxes!<br><br>";
}
$i++;
}
}
}
$obj = new employee;
$obj->populate();
$obj->checkTaxes();
?>