Maybe better sollution:
class base {
protected $_vars = array();
public function setVar($name, $value = null) {
$this->_vars[$name] = $value;
}
public function getVar($name) {
return isset($this->_vars[$name]) ? $this->_vars[$name] : null;
}
}
And simply extend this class. Or also you can use __set and __get methods, but they are quite slower.