php - Why do I type parent::__construct? -


each time go declare extended class,

class cookies extends food{     public function __construct()     {         parent::__construct();     } } 

why using parent::__construct()?

is inheritance? merely extending class not inherit it's properties?

if that's sole content of child class constructor, don't need define child constructor @ all, , run parent constructor.

if create child class constructor, child constructor run instead of parent class constructor (even if it's empty body); if need run parent class's constructor as well need call explicitly using parent::__construct()


Comments