面向对象,继承与魔术方法的问题

浏览:1176 发布日期:2014/01/21 分类:求助交流 关键字: 面向对象
class Father{
    function __set($name,$value) {
        $this->$name = $value;
    }
}

class Son extends Father {
    private $height = 180;
    
    function __get($name) {
        return $this->$name;
    }
}

$son = new Son();

$son->height = 170;

echo $son->height;
这个为什么打印180而不是170
最佳答案
评论( 相关
后面还有条评论,点击查看>>