Re: Question regarding constructors and child classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Comment inline

On Wed, 17 Nov 2004 20:19:01 -0600, Brent Clements
<bclem@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> 
> <?php
> 
> class foo {
> 
>           function foo () {
> 
>                 echo "constructed!";
> 
>             }
> 
> }
> 
> class childFoo extends foo {
> 
>             function childFoo() {
> 

// here you should call the parent constructor:
                       parent::foo()
// also you could do this other way (I prefer the one above):
                       $this->foo()

>                         echo "constructed also!";
> 
>             }
> 
> }
> 
> $a = new childFoo();
> 
> ?>
> 
> Is there any way to run both the parent and child constructor? 

http://www.php.net/manual/en/language.oop.constructor.php
http://www.php.net/manual/en/language.oop5.decon.php

Regards,
Jordi.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux