Re: splitting a class across separate files?
| From: | Monte Ohrt | Date: | Thu, 08 Feb 2001 17:18:02 +0000 |
| Subject: | Re: splitting a class across separate files? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-38780@lists.php.net to get a copy of this message | ||
I guess my problem is that the condition happens within a function of
the class. I'll have to figure out a way around that.
Chris Lee wrote:
>
> Its called inheritance.
> rarley.php
> <?php
>
> class rarley_used
> {
> function one()
> {
>
> }
>
> function two()
> {
>
> }
> }
> ?>
>
> main_class.php
> <?php
>
> include_once('rarley.php');
>
> class main_class extends rarley_used
> {
> function three()
> {
>
> }
>
> function four()
> {
>
> }
> }
> ?>
>
> --
>
> Chris Lee
> Mediawaveonline.com
> lee@mediawaveonline.com
>
> "Monte Ohrt" <monte@ispi.net> wrote in message
> news:3A82BF83.8E84D16@ispi.net...
> > I have a class with many functions. About 80% of these functions are
> > rarely used, so I'd like to split them out to a separate file and
> > include them only if a certain condition applies. This way the PHP
> > compiling is kept to a minimum. How do I make the included functions
> > members of the current class?
> >
> > Example:
> >
> >
> > myclass.php
> > -----------
> >
> > <?php
> >
> > class MyClass {
> >
> > function func1() {
> > if($foo) {
> > include_once("myclass2.php");
> > $this->func2(); // this doesn't work, it won't find func2!
> > }
> > }
> >
> > }
> >
> > ?>
> >
> > myclass2.php
> > ------------
> >
> > <?php
> >
> > // I need these functions to be
> > // members of MyClass... how?
> > function func2() {
> > // do something
> > }
> >
> > }
> >
> > ?>
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/