splitting a class across separate files?
| From: | Monte Ohrt | Date: | Thu, 08 Feb 2001 15:47:15 +0000 |
| Subject: | splitting a class across separate files? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-38769@lists.php.net to get a copy of this message | ||
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
}
}
?>