<?php
class Student {
// Properties
public $name;
public $age;
public $department;
// Methods
function set_name($name) {
$this->name = $name;
}
function get_name() {
return $this->name;
}
function set_age($age) {
$this->age = $age;
}
function get_age() {
return $this->age;
}
function set_department($department) {
$this->department = $department;
}
function get_department() {
return $this->department;
}
}
//New student
$nkemjika = new Student();
$nkemjika->set_name('Nkemjika');
$nkemjika->set_age(22);
$nkemjika->set_department('School of Medicine');
//New student
$chioma = new Student();
$chioma->set_name('Chioma');
$chioma->set_age(20);
$chioma->set_department('School of Medicine');
echo "<br>";
echo "Name: " . $nkemjika->get_name();
echo "<br>";
echo "Age: " . $nkemjika->get_age();
echo "<br>";
echo "Department: " . $nkemjika->get_department();
echo "<br>";
echo "<br>";
echo "Name: " . $chioma->get_name();
echo "<br>";
echo "Age: " . $chioma->get_age();
echo "<br>";
echo "Department: " . $chioma->get_department();
?>
Output
Name: Nkemjika
Age: 22
Department: School of Medicine
Name: Chioma
Age: 20
Department: School of Medicine