Call parent static method in php

2020-03-08 08:54发布

I have a base class A:

class A {
   public static function a() {
      ...
   }
   public static function b() {
      ...
   }
}

and an extended class B

class B extends A {
   public static function a() {
      ...
   }
   public static function c() {
      ...
   }
}

I would like to be able to call all the methods using B:: How would I call A::b, using B::?

1条回答
倾城 Initia
2楼-- · 2020-03-08 09:54

You should be able to accomplish this as easily as:

class B extends A {
   public static function a() {
      parent::a();
   }
}

See the docs

查看更多
登录 后发表回答