PHP: “Declaration of … should be compatible with that of …”

前端 未结 2 1826
温柔的废话
温柔的废话 2021-01-06 07:13

I\'d like to create an interface for entities that are CRUDable (can be saved and deleted). Here is my abstract class:

abstract class AbstractCrudableEntity          


        
相关标签:
2条回答
  • 2021-01-06 07:31

    Overriding constructors is a special case:

    Unlike with other methods, PHP will not generate an E_STRICT level error message when __construct() is overridden with different parameters than the parent __construct() method has.

    You can not do that with other methods.

    0 讨论(0)
  • 2021-01-06 07:42

    Your child methods must have the same number of parameters as the abstract methods in an abstract parent class.

    The constructor in you example is not abstract--the child is just overriding it.

    0 讨论(0)
提交回复
热议问题