mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
- Look for missing classes in include_path
This commit is contained in:
parent
e72a305091
commit
c122763bc0
1 changed files with 24 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue