How to include() all PHP files from a directory?
Here is the way I include lots of classes from several folders in PHP 5. This will only work if you have classes though.
/*Directories that contain classes*/$classesDir = array ( ROOT_DIR.'classes/', ROOT_DIR.'firephp/', ROOT_DIR.'includes/');function __autoload($class_name) { global $classesDir; foreach ($classesDir as $directory) { if (file_exists($directory . $class_name . '.php')) { require_once ($directory . $class_name . '.php'); return; } }}
I realize this is an older post BUT... DON'T INCLUDE YOUR CLASSES... instead use __autoload
function __autoload($class_name) { require_once('classes/'.$class_name.'.class.php');}$user = new User();
Then whenever you call a new class that hasn't been included yet php will auto fire __autoload and include it for you