多年前,我为我的网站使用了一个简单的php博客平台,这使用了旧的__autoload函数.我最近不得不迁移主机,他们使用了一个新版本的php,所以这个功能不再起作用.我try 用spl_autoload_register替换_autoload,但标题中出现错误.我不熟练的php和我不能弄清楚如何解决这个问题自己.下面是我的php文件中的代码.
//load classes as needed
function spl_autoload_register($class) {
$class = strtolower($class);
//if call from within assets adjust the path
$classpath = 'classes/class.'.$class . '.php';
if ( file_exists($classpath)) {
require_once $classpath;
}
//if call from within admin adjust the path
$classpath = '../classes/class.'.$class . '.php';
if ( file_exists($classpath)) {
require_once $classpath;
}
//if call from within admin adjust the path
$classpath = '../../classes/class.'.$class . '.php';
if ( file_exists($classpath)) {
require_once $classpath;
}
}