Re: Multiple Class Inheritance

From: Date: Wed, 27 Jan 2010 15:18:55 +0000
Subject: Re: Multiple Class Inheritance
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-301550@lists.php.net to get a copy of this message
2010/1/27 Ryan Sun <ryansun81@gmail.com>: > 1, you can implement multiple interfaces > > 2, you may want to return object instead of extending classes, > eg. > class Small_Class_Abstract > { >  public function getFormGeneration() >  { >    return new Form_Generation(); >  } > } > class Small_Class_A extends Small_Class_Abstract > { > } > $A = new Small_Class_A(); > $form = $A->getFormGeneration()->newForm(); > > On Wed, Jan 27, 2010 at 7:52 AM, Ashley Sheridan > <ash@ashleysheridan.co.uk>wrote: > >> Hi All, >> >> I know that a class can only inherit from one other single class in PHP, >> but how would I go about simulating a multiple class inheritance? For >> example, if I had several small classes that dealt with things like form >> generation, navbar generation, etc, how could I create a class in which >> these all existed? >> >> Or am I thinking about this the wrong way? Should I have keep the >> smaller classes, and have one larger object containing instances of each >> as and how are necessary? >> >> I've used classes before, but I'm fairly new to class inheritance, and >> more particularly, the complex inheritance like I describe here. >> >> Thanks, >> Ash >> http://www.ashleysheridan.co.uk >> >> >> > The Decorator pattern is an option here too I would guess. -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling

« previous php.general (#301550) next »