子类调用父类中重写的静态成员

原创 2019-02-16 00:07:23 287
摘要://父类调用子类中重写的静态成员class Father {     public static $money = 10000;     public static function getMoney(){   &nbs

//父类调用子类中重写的静态成员

class Father
{
    public static $money = 10000;
    public static function getMoney(){
        return static::$money;
    }
}

class Son extends Father
{
    public static $money = 30000;

}
echo Son::getMoney();


批改老师:天蓬老师批改时间:2019-02-16 09:02:53
老师总结:public static $money = 10000; public static function getMoney(){ return static::$money; 对于需要用子类访问的成员, 可见性应该定义为: protected

发布手记

热门词条