Karel is een customer.
Ilse is een employee.
<?php
abstract class User {
protected $_username;
public function __construct($name) {
$this->_username = $name;
}
public function getUsername() {
return $this->_username;
}
public abstract function getUserStatus();
}
class Customer extends User {
private $_customerId;
public function __construct($username, $id) {
$this->_username = $username;
$this->_customerId = $id;
}
public function getUserStatus() {
return 'customer';
}
}
class Employee extends User {
private $_employeeId;
public function __construct($username, $id) {
$this->_username = $username;
$this->_employeeId = $id;
}
public function getUserStatus() {
return 'employee';
}
}
$jan = new Customer('Karel', 1);
$inge = new Employee('Ilse', 1);
echo 'Karel is een '.$jan->getUserStatus().'. <br />';
echo 'Ilse is een '.$inge->getUserStatus().'.';
show_source(__FILE__);
?>