user1426048
user1426048

Reputation:

PHP -If we create object of child class in php, does it call parent class constructor and then child class constructor like java?

PHP -If we create object of child class in php, does it call parent class constructor and then clild class constructor like java?

Upvotes: 2

Views: 91

Answers (1)

xdazz
xdazz

Reputation: 160883

No, you need to call the parent constructor in child class.

public function __construct() {
  parent::__construct();
  //...other code
}

Upvotes: 1

Related Questions