CODE
<?php
function __autoload($class) {
include("inc/$class.php");
}
$myclass = new MyClass();
?>
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.