diff options
author | Marcus Boerger <helly@php.net> | 2004-05-02 22:55:22 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2004-05-02 22:55:22 +0000 |
commit | c122763bc0fbd1cd64933af7d60ddcfb1feccb4f (patch) | |
tree | ebc1073ef06e80314fff611545476cae91df33d6 /ext/spl/examples | |
parent | e72a305091f309e5b125f9537f45414a09924ae5 (diff) | |
download | php-git-c122763bc0fbd1cd64933af7d60ddcfb1feccb4f.tar.gz |
- Look for missing classes in include_path
Diffstat (limited to 'ext/spl/examples')
-rwxr-xr-x | ext/spl/examples/autoload.inc | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/ext/spl/examples/autoload.inc b/ext/spl/examples/autoload.inc index 34072f8e4a..430680645a 100755 --- a/ext/spl/examples/autoload.inc +++ b/ext/spl/examples/autoload.inc @@ -1,7 +1,30 @@ <?php +function __load_class($classname, $dir) +{ + $file = $dir . '/' . $classname . '.inc'; + if (file_exists($file)) + { + require_once($file); + return true; + } + return false; +} + function __autoload($classname) { - require_once(dirname($_SERVER['PATH_TRANSLATED']).'/'.strtolower($classname).'.inc'); + $classname = strtolower($classname); + foreach(split(':', ini_get('include_path')) as $dir) + { + if (__load_class($classname, $dir)) + { + fprintf(STDERR, 'Loading class('.$classname.")\n"); + return; + } + } + if (!__load_class($classname, '.')) + if (!__load_class($classname, dirname($_SERVER['PATH_TRANSLATED']))) + fprintf(STDERR, 'Class not found ('.$classname.")\n"); + return; } ?>
\ No newline at end of file |