Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10797 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52940 invoked by uid 1010); 27 Jun 2004 06:44:50 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 52916 invoked from network); 27 Jun 2004 06:44:50 -0000 Received: from unknown (HELO vw.zworg.com) (207.36.180.93) by pb1.pair.com with SMTP; 27 Jun 2004 06:44:50 -0000 Received: (qmail 30362 invoked by uid 502); 27 Jun 2004 06:44:45 -0000 To: swalk@prp.physik.tu-darmstadt.de Cc: internals@lists.php.net Date: Sat, 26 Jun 2004 23:44:45 -0700 Message-ID: <30356.1088318685@zworg.com> Subject: Re: [PHP-DEV] Base and derived class construction From: jdavidson@zworg.com ("Jason Davidson") which languages is this normal too.. if you refer to java, that uses the 'super' function, you need only explicitly call super if your constructor has arguments, otherwise an implicit call is made to the parents defualt constructor ( one with arguments). c++ also will call the parent defualt constructor automatically as well i beleive. that aside, i do release my mistake in the workaround, ive noted the use of parent::__construct(). im not really concerned with coding, i was more simply interested in why it was done this way, in such a way, that a child class can be inherited with parent class construction. Jason Stefan Walk wrote: > > On Sat, Jun 26, 2004 at 08:03:12PM -0700, Jason Davidson wrote: > > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >