By submitting PHP Resources you own, or know of, you'll help us build the largest PHP Resource website on the net. Please double check that your resource doesn't already exist before you submit it!!. We thank you for helping make this a better website.
In driver-based packages you should check if the driver exists before
loading it. A simple file_exists() does not work
since it does not check the
include path.
fopen()'s third parameter does that, so we use it.
<?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;
//...
?>