Re: How to call parent's class constructor?
| From: | Matthew Kendall | Date: | Sat, 24 Jun 2000 21:51:17 +0000 |
| Subject: | Re: How to call parent's class constructor? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-2933@lists.php.net to get a copy of this message | ||
"Jon Parise" <jon@csh.rit.edu> wrote ...
> On Sat, Jun 24, 2000 at 08:39:08PM +0200, Sebastian Bergmann wrote:
>
> > class Foo
> > {
> > // constructor
> > function Foo() { ... }
> > }
> >
> > class FooBar
> > {
> > // constructor
> > function FooBar() { ... }
> > }
> >
> > Now I need to call Foo's constructor from within FooBar's constructor.
>
> I believe Foo::Foo() will work.
Is this :: notation PHP4 specific? I doesn't work for me.
What I usually do is:
class Foo
{
// constructor
function Foo() { ... }
}
class FooBar extends Foo
{
// constructor
function FooBar() {
$this->Foo();
}
}