At time sincluding a bunch of class files can become very messy, and sometimes those included pages are never used. Good thing for us that a new function available only for PHP 5 is the autoload class.

CODE
<?php
 
 function __autoload($class) {
   include("inc/$class.php");
 }

 $myclass = new MyClass();

?>


In the above example, PHP will check is there are any missing classes. If there is then the __autoload class will include the file when needed. I have found that when working with much larger projects, in which case use a config file, it is best to have the __aotoload function somewhere in the config file. This will ensure that all pages will have access to all classes.

Oh, by the way. I must say again. This will not work in PHP 4 or below.