0

If There are no parent::__construct from parent class then

How we can add construct into overridden class?

  • Did you resolve your issue? – Shoaib Munir Jul 23 at 9:29
0

Normally when add constructor in a class then we also call it's parent class's constructor inside current class constructor, like this:

public function __construct()
{
    parent::__construct(/*Some parems here*/);
}

The parameters in calling of parent class's constructor depends on the parent constructor's parameters, those should be equal.

But, if parent class does not have any constructor then we simply defined our constructor and we do no call parent constructor like this:

public function __construct()
{
    //Your code here
}

There is no issue of adding constructor to child class if parent class has no constructor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.