Re: PHP class question

From: Date: Thu, 21 May 2009 19:08:11 +0000
Subject: Re: PHP class question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-292901@lists.php.net to get a copy of this message
Peter van der Does wrote: > I have the following situation. > > I wrote some software and split it up into functionality: > > class core { > function go{ > } > } > > class A extends core { > // PHP4 constructor > function A { > $this->go(); > } > > } > > class B extends core { > } > > In core I define functions and variables that are to be used > through out my program and to address those functions/variables I just > use $this-> . > > Now I ran into a situation where class A needs to be extended with > another class. This is not my choice, it's part of a framework I have > to use. This doesn't make sense. You say "class A needs to be extended with another class", however what you show below is "class A extending framework_class". Show your classes and we can help I think. > Currently I solved this by doing this: > > class A extends framework_class { > $var core; > > // PHP4 constructor > function A { > $this->core = new core(); > $this->core->go(); > } > } > > The question I have, is this a good solution, is it the only solution > or are there different ways to tackle this? > As you might see it needs to run in PHP4. > I'm sure there are. This doesn't look right to me, but I'm confused by your examples. -- Thanks! -Shawn http://www.spidean.com

« previous php.general (#292901) next »