Ejemplo n.º 1
0
    {
        echo __METHOD__ . "({$name})\n";
        return isset($this->dynamicProperties[$name]);
    }
    public function __unset($name)
    {
        echo __METHOD__ . "({$name})\n";
        unset($this->dynamicProperties[$name]);
    }
}
$p = new Point(5, 9);
echo "----------------------\n";
$v = $p->dummy;
// get visible property
echo "dummy: {$v}\n";
$v = $p->__get('dummy');
// get dynamic property, if one exists; else, fails
echo "dynamic dummy: {$v}\n";
$p->dummy = 987;
// set visible property
$p->__set('dummy', 456);
// set dynamic property
$v = $p->dummy;
// get visible property
echo "dummy: {$v}\n";
$v = $p->__get('dummy');
// get dynamic property
echo "dynamic dummy: {$v}\n";
echo "----------------------\n";
var_dump(isset($p->dummy));
// test if dummy exists and is accessible, or is dynamic