我在我的函数文件 (MyFunctions.php) 中放置了以下代码:
spl_autoload_register
(
function( $Class )
{
$Class = str_replace ( "..", "", $Class );
include $_SERVER['DOCUMENT_ROOT'] . '/phpsb/class library/' . $Class . '.php';
}
);
但是,当我从脚本中引用类/对象时,spl_autoload_register
会在定义它的函数文件中搜索,而不是在类库目录中搜索:
Warning: include(C:/xampp/htdocs/phpsb/class library/FormClass.php): failed to open stream: No such file or directory in C:\xampp\htdocs\sandbox\function library\MyFunctions.php