Enforcing property access using magic accessor methods
<?
class Person {
protected $__data = array('person', 'email');
public function __get($property) {
if (isset($this->__data[$property])) {
return $this->__data[$property];
} else {
return false;
}
}
public function __set($property, $value) {
if (isset($this->__data[$property])) {
return $this->__data[$property] = $value;
} else {
return false;
}
}
}
?>
Related examples in the same category