简体   繁体   中英

Call parent static method in php

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::?

You should be able to accomplish this as easily as:

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

See the docs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM