Abstract Static Function in PHP 5.3

后端 未结 2 363
青春惊慌失措
青春惊慌失措 2021-02-04 11:02

I\'m a relative newcomer to PHP, and I\'m figuring out the best way to implement some database access code. I\'m trying to create some simple database access objects -- each ta

2条回答
  •  再見小時候
    2021-02-04 11:46

    An abstract function will never be static, in any kind of language.

    A static function provide a functionality, even if there is no instance.

    An abstract function doesn't provide any functionnality.

    Logically, you can't use an abstract static function, which would --ALWAYS AND NEVER-- provide a functionnality.


    B extends A

    When you call a static function in B context, it'll be runned in A context (cause of static state).

    But, in A context, this same function is abstract, an you're not allowed to call it.

提交回复
热议问题