I\'m working on a project whereby I have the following file structure:
index.php |---lib |--|lib|type|class_name.php |--|lib|size|example_class.php >
index.php |---lib |--|lib|type|class_name.php |--|lib|size|example_class.php
function __autoload($class_name) { $class_name = strtolower($class_name); $path = "{$class_name}.php"; if (file_exists($path)) { require_once($path); } else { die("The file {$class_name}.php could not be found!"); } }
UPDATE: __autoload() is deprecated as of PHP 7.2
__autoload()