Why can't you call abstract functions from abstract classes in PHP?

前端 未结 3 2035
花落未央
花落未央 2020-12-14 13:56

I\'ve set up an abstract parent class, and a concrete class which extends it. Why can the parent class not call the abstract function?

//foo.php


        
3条回答
  •  别那么骄傲
    2020-12-14 14:41

    It's a rule that abstract and static keywords can not be use on a method at the same time.

    A method with an abstract keyword means that sub-class must implement it. Adding static to a method of a class allows us to use the method without instantiating it.

    So that is why the error occurs.

提交回复
热议问题