<?php
$driver = 'SomeDriver';
$class = 'My_Package_Driver_' . $driver;
$file = str_replace('_', '/', $class) . '.php';
//check if it exists and can be loaded
if (!@fclose(@fopen($file, 'r', true))) {
throw new My_Package_Driver_Exception(
'Driver ' . $driver . ' cannot be loaded.'
);
}
//continue with including the driver
require_once $file;
//...
?>