Calling a derived static method from a method in parent class in PHP

This question already has an answer here:

  • What exactly are late static bindings in PHP? 7 answers

  • You use late static binding for this

    Basically in the abstract class you call static::method() . This uses the method of the class that made the call.

    Abstract Class A{
        public function foo(){
            // Late static binding
            static::bar();
        }
    
       abstract public static function bar();
    }
    
    链接地址: http://www.djcxy.com/p/58030.html

    上一篇: 函数重写需要实例吗?

    下一篇: 在PHP中用父类中的方法调用派生的静态方法