Are abstract class constructors not implicitly called when a derived class is instantiated?

No, the constructor of the parent class is not called if the child class defines a constructor.

From the constructor of your child class, you have to call the constructor of the parent’s class :

parent::__construct();

Passing it parameters, if needed.

Generally, you’ll do so at the beginning of the constructor of the child class, before any specific code ; which means, in your case, you’d have :

class Child extends Base {
    function __construct() {
        parent::__construct();
        echo 'Child __construct<br/>';
    }
}

And, for reference, you can take a look at this page of the PHP manual : Constructors and Destructors — it states (quoting) :

Note: Parent constructors are not called implicitly if the child class
defines a constructor.
In order to
run a parent constructor, a call to
parent::__construct() within the
child constructor is required.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)