I have another question about OO in PHP --
The manual (http://www.php.net/manual/en/language.oop.constructor.php)
does an excellent job of explaining how constructors in extended classes
work when there are constructors in base classes. I understand that no
problem. But at the bottom of the page is a cautionary note:
<cautionary_note>
Neither PHP 3 nor PHP 4 call constructors of the base class
automatically from a constructor of a derived class. It is your
responsibility to propagate the call to constructors upstream where
appropriate.
</cautionary_note>
This is where I am uncertain -- how do I call an upstream constructor
from an instance of an extended class, where I have a constructor in the
extended class? IOW:
<?php
class ClassA
{
function ClassA($var)
{
print "ClassA object instantiated, argument is $var";
}
}
class ClassB
{
function ClassB($var)
{
print "ClassB object instantiated, argument is $var";
}
}
$instance = new ClassB(frank);
// this should print "ClassB object instantiated, argument is frank"
My question is, how do I call the constructor of ClassA? To see the
following results:
// "ClassB object instantiated, argument is frank"
// "ClassA object instantiated, argument is bob"
Erik
----
Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php