Currently in an application i include classes from a directory (any number of classes could be dropped into this directory). Although i would like to go a step further and be able to create an array of class instances or class names CLASS from these files… is this possible when the class files are dropped into the folder? below is the code i currently use to include the files (php4 compat)
// Include custom field types, as drop-ins
$include_files = (array) glob( METAMAKER_FIELDS_DIR."*.php" );
if( is_array($include_files) ) {
foreach($include_files as $filename) {
if (!empty($filename) && strstr($filename, 'php')) {
include_once($filename);
}
}
}
Join us in the 21st century and use Autoloading. This is especially recommended, because with your approach its more complicated to ensure, that every dependency is resolved in the right order. Just don’t do it this way.