<?php
class Human
{
private $name;
private $gender;
public function __construct($name, $gender)
{
$this->name = $name;
$this->gender = $gender;
}
public function getGender()
{
return $this->gender;
}
public function setGender($gender)
{
$this->gender = $gender;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
}
class Student extends Human
{
private $id;
private $score;
public function __construct($id, $score, $name, $gender)
{
parent::__construct($name, $gender);
$this->id = $id;
$this->score = $score;
}
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
}
public function getScore()
{
return $this->score;
}
public function setName($score)
{
$this->score = $score;
}
}
class Employee extends Human
{
private $id;
private $salary;
public function __construct($id, $salary, $name, $gender)
{
parent::__construct($name, $gender);
$this->id = $id;
$this->salary = $salary;
}
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
}
public function getSalary()
{
return $this->salary;
}
public function setSalary($salary)
{
$this->salary = $salary;
}
}
$student = new Student('st01', 6.7, 'name 1', 'male');
echo '<h4>Student Info</h4>';
echo 'id: ' . $student->getId();
echo '<br>name: ' . $student->getName();
echo '<br>gender: ' . $student->getGender();
echo '<br>score: ' . $student->getScore();
$employee = new Employee('e01', 1000, 'name 2', 'female');
echo '<h4>Employee Info</h4>';
echo 'id: ' . $employee->getId();
echo '<br>name: ' . $employee->getName();
echo '<br>gender: ' . $employee->getGender();
echo '<br>score: ' . $employee->getSalary();
?>
Student Info
id: st01
name: name 1
gender: male
score: 6.7
Employee Info
id: e01
name: name 2
gender: female
score: 1000