When working with classes I have found the __autoload() function very nice. It saves you from haveing a tone of require once() statements.

if you name your classes using the naming convention of the PEAR project you could do this.

function __autoload($classname){ $path = str_replace('_', DIRECTORY_SEPARATOR, $classname); $path = $_SERVER[DOCUMENT_ROOT]."/$path.php"; require_once($path); }

The naming convention is one '_' for every '/' in the directory path to get to your file.

So /home/docs/public_html/project/classes/myclass.php could be
class classes_myclass{ /* class code here */ }

$_SERVER[DOCUMENT_ROOT] should fill in /home/docs/public_html/project. What __autoload does is if a attempt to call the class fails it will hit the function I gave and try one last time to open and used the file needed. This allows you to only call files as needed. You can then add a bit more abtration to your classes.

I have yet to get this to work within a class though or work with a class method that creates a new object.

Edited by Gizmo (01/03/07 05:12 PM)
My New site OpenEyes