コード例 #1
0
ファイル: overloading.php プロジェクト: mfsousa/php-langspec
    {
        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
var_dump($p->__isset('dummy'));
// test if dynamic dummy exists
echo "----------------------\n";
$v = $p->x;
// try to get at an invisible property; can't. The runtime sees that x