inheritance question
Posted: Mon Mar 17, 2003 7:59 am
I have classes inheritance something like this small example
look at the comment in the constructor of B, i want (if there is a away )
to call the constructor of A from B and still call dosomthing function of A and not B.
can it be done?
Thanks
Guy
Code: Select all
<?PHP
class A
{
function A()
{
$this->dosomething();
}
function dosomething()
{
echo "in A<br>";
}
}
class B extends A
{
function B()
{
$this->A(); //will print 'in B'
$this->dosomething(); //will print 'in B'
A::A(); //will print 'in B'
A::dosomething(); //will print 'in A'
}
function dosomething()
{
echo "in B<br>";
}
}
$b = new B;
?>to call the constructor of A from B and still call dosomthing function of A and not B.
can it be done?
Thanks
Guy