Exemplo n.º 1
0
 /**
  * Callback for class autoloading.
  *
  * @param string $class
  * @return AutoLoader
  */
 public function autoload($class)
 {
     $class = str_replace("\\", "_", $class);
     $class = getClassPath($class);
     $classFile = array();
     $classFile[] = $class . ".php";
     $classFile[] = "Util/" . $class . ".util.php";
     if ($file = file_exists_inc($classFile)) {
         require_once $file;
     }
     return $this;
 }
Exemplo n.º 2
0
/**
 * Check if a file exists in the include path.
 *
 * @param string|array	Name of the file to look for
 *
 * @return mixed	The full path if file exists, false otherwise
 */
function file_exists_inc($file)
{
    if (is_array($file)) {
        foreach ($file as $_file) {
            if ($fullpath = file_exists_inc($_file)) {
                return $fullpath;
            }
        }
        return false;
    }
    $paths = explode(PATH_SEPARATOR, get_include_path());
    foreach ($paths as $path) {
        $fullpath = $path . $file;
        if (file_exists($fullpath)) {
            return $fullpath;
        }
    }
    return false;
}