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

Reply via email to