Posted by ybakos on 07/12/06 15:52
I don't quite get what you're trying to accomplish (but I'm not that
bright).
You should avoid deep inheritance heirarchies.
Or perhaps you shouldn't override the methods in this manner, since you
are trying to achieve the ability to 'reach back' up the inheritance
chain to call the 'Grandparent' method.
Not sure if this helps.
Cheers,
Yong
Jeff North wrote:
> My OOP knowledge is flaky, at best, so please be patient with me :-)
>
> I've downloaded the FPDF class from www.fpdf.org as well as some of
> the scripts that are available.
>
> Each of these scripts use:
> class mine extends FPDF {}
> which is what you'd expect when extending out to a new class.
>
> What I want/would like to do is to include multiple scripts which
> extend the base class of FPDF. I've managed to daisy-chain these
> classes similar to:
> -------------------------------------------------------------------------
> <?php
> class FPDF {
> function FPDF(){ echo "class FPDF<BR>";}
> function setSize(){ echo "setSize_FPDF()<BR>";}
> }
> class B extends FPDF {
> function B(){ echo "class B<BR>";}
> function setSize(){ echo "setSize_B()<BR>......";parent::setSize();}
> }
> class C extends B {
> function C(){ echo "class C<BR>";}
> function setLimit(){ echo "setLimit_C()<BR>";}
> }
> class D extends C {
> function D(){ echo "class D<BR>";}
> function PrintLine(){ echo "PrintLine_D()<BR>";}
> }
> class me extends D {
> function me(){ echo "class me<BR>";}
> function setSize()
> {
> echo "setSize_E()<BR> ";
> //--- this only gets the class B function
> parent::setSize();
> }
> }
> //--- test code
> $x = new me();
> $x->FPDF();
> $x->PrintLine();
> $x->setSize();
>
> /* --- output
> class me
> class FPDF
> PrintLine_D()
> setSize_E()
> setSize_B()
> setSize_FPDF()
> */
> ?>
> -------------------------------------------------------------------------
> Now even *I* know that OOP was never intended to be like this. Is
> there a better/correct way?
>
> In my code how would I reference the FPDF setSize() method?
> FYI: the setSize is not overriding the base class, it is an internal
> function to that class only.
> ---------------------------------------------------------------
> jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
> ---------------------------------------------------------------
[Back to original message]
|