如何在子构造函数之前运行父类构造函数? (PHP)[重复]

This question already has an answer here:

How can I make the parent constructor run before the child's constructor? ( Code: )

class database{
    public function __construct(){
        // Connect to database
    }
}

class child extends database{
    public function __construct(){
        // Do something
    }
}

I want it to connect to the database and then run the child's constructor, is that possible?

</div>

Add parent::__construct() to the start of the child __construct().

Like this:

class child extends database{
    public function __construct(){
        parent::__construct();
        // Do something
    }
}