PHP Scriptlets

Here is a sample method for loading stuff dynamically

public static function loadClass($class)
{
        if (class_exists($class, false) ||
                interface_exists($class, false))
        {
                return;
        }
 
        $file = YOUR_LIB_ROOT.$class.'.php';
 
        if (file_exists($file))
        {
                include_once $file;
                if (!class_exists($class, false) &&
                        !interface_exists($class, false))
                {
                        throw new Exception('File '.$file.' was loaded but class '.$class.' was not found');
                }
        }
}
 
 phpscriptlet.txt · Last modified: 2011/09/06 08:06 by bpienig
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Recent changes RSS feed Driven by DokuWiki