Page 1 of 1

Possible to define methods outside the class?

Posted: Wed Jul 16, 2008 10:50 am
by gavagai
Hi,

Can anyone tell me if it's possible to define methods of a class outside the original class definition - specifically, in a seperate include file?

Thanks,

Tom

Re: Possible to define methods outside the class?

Posted: Wed Jul 16, 2008 10:58 am
by dhrosti
As far as I know its not possible.

What are you trying to achieve? there might be an alternative solution...

Re: Possible to define methods outside the class?

Posted: Wed Jul 16, 2008 11:03 am
by Benjamin
Is this a homework or job interview question?

Re: Possible to define methods outside the class?

Posted: Wed Jul 16, 2008 11:10 am
by gavagai
Well the aim is just to tidy up a big class and move deprecated methods into a seperate file

Re: Possible to define methods outside the class?

Posted: Wed Jul 16, 2008 11:14 am
by Benjamin
You can extend existing classes quite easily.

http://php.benscom.com/manual/en/keyword.extends.php

Re: Possible to define methods outside the class?

Posted: Wed Jul 16, 2008 11:22 am
by Eran
A better solution might be to use object composition. http://www.artima.com/lejava/articles/d ... ples4.html