<?php
class Data {
private $data = array();
public function __set($name, $value) {
$this->data[$name] = $value;
}
public function __get($name) {
if (isset($this->data[$name])) { return $this->data[$name]; }
}
public function __isset($name) {
return isset($this->data[$name]);
}
public function __unset($name) {
unset($this->data[$name]);
}
}
$data = new Data();
$data->name = 'F';
echo "<p>The data value of 'name' is {$data->name}</p>";
unset($data->name);
echo '<p>The value is ', isset($data->name) ? '' : 'not ', 'set.</p>';
?>
|