Question regarding constructors and child classes

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

 



If I have the following: 

 

 

 

<?php

 

class foo {

 

          function foo () {

                echo "constructed!";

 

            }

 

}

 

 

 

class childFoo extends foo {

 

            function childFoo() {

 

                        echo "constructed also!";

 

            }

 

}

 

 

 

$a = new childFoo();

 

 

 

?>

 

 

 

Is there any way to run both the parent and child constructor? The reason
I'm asking this is because in my parent class, the constructor creates the
database connection, in the child constructor it set's up all variables for
the child class.

 

 If I recall, I can do a "parent::constructorname()", is there a way to call
the parent's constructor more cleanly, to me , stylewise, it looks funny to
have parent::foo().

 

 

 

How would I do this?

 

 

 

-Brent


[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