我正在更新我的代码并尝试使用 spl_autoload_register 但它根本不起作用!!!我在 Centos / Ubuntu / Win7 上使用 PHP 5.3.8 - Apache 2.22 并试图回应一些东西,但我什么也没得到......一直试图让它在过去 3 个小时内工作但没有结果......这是快把我逼疯了!!!
class ApplicationInit {
// Constructor
public function __construct() {
spl_autoload_register(array($this, 'classesAutoloader'));
echo 'construct working...!';
}
// Autoloading methods
public function classesAutoloader($class) {
include 'library/' . $class . '.php';
echo 'autoload working...!';
}
}
来自 __construct 的第一个回显有效,但“classesAutoloader”根本不起作用,此类定义在文件夹内的 php 文件中,我从 index.php 调用它,如下所示:
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', getcwd() . DS);
define('APP', ROOT . 'application' . DS);
// Initializing application
require(APP.'appInit.php');
$classAuto = new ApplicationInit();
任何帮助都非常感谢,在此先感谢!