# Base and derived class construction

- Thread: https://externals.io/message/10792
- Original archive: https://news-web.php.net/php.internals/10792
- Started by Jason Davidson on 2004-06-27T03:03:12+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #10792 — Jason Davidson — 2004-06-27T03:03:12+00:00

URL: https://externals.io/message/10792#10792

Hi, is there a reason that when a child class is instantiated the parent
class constructor does not get called?
The obvious workaournd for this is to simply call
$this->parentConstructor(); in the child class constructor, however,
this seems strange.. 

Am i way off base here...?

Thanks
Jason

---

## #10796 — Stefan Walk — 2004-06-27T06:30:58+00:00

URL: https://externals.io/message/10792#10796 · In reply to: #10792

> Hi, is there a reason that when a child class is instantiated the parent
> class constructor does not get called?
> The obvious workaournd for this is to simply call
> $this->parentConstructor(); in the child class constructor, however,
> this seems strange.. 

parent::__construct(), to be exact :)

> 
> Am i way off base here...?
> 
> Thanks
> Jason

Most languages i know do that ("forcing" you to call super or alike).
The only small "annoyance" i see is that parent::__construct() doesn't
automatically use the parameters that were passed to the constructor,
but i think one can live with that.

Stefan
