class foo
{
protected $bar = 'qwerty';
public function __get($name)
{
if ('bar' === $name) return $this->bar;
return 'not found';
}
public function __set($property, $value)
{
if ('bar' === $property) $this->bar = $value;
}
}
$f = new foo();
echo $f->bar; // qwerty
echo $f->asd; // not found
$f->bar = 'zxc';
echo $f->bar; // zxc