我在活动服务器上面临一个PHP错误。我相信这是一个版本问题。
此错误包括在下面,并发生在config.php文件中:-
ERROR: __autoload() is deprecated, use spl_autoload_register() instead.
来自文件的代码片段
if (!function_exists('__autoload')) {
function __autoload($class) {
if (strpos($class, 'Auth_Controller') === 0) {
@include_once( APPPATH . 'core/' . $class . EXT );
}
if (strpos($class, 'Rest_Controller') === 0) {
@include_once( APPPATH . 'core/' . $class . EXT );
}
}
}发布于 2019-11-26 09:41:11
使用spl_autoload_register添加类加载器函数。
在找到类之后结束函数也是一个很好的实践。
$autoload = function ($class) {
if (strpos($class, 'Auth_Controller') === 0) {
@include_once( APPPATH . 'core/' . $class . EXT );
return;
}
if (strpos($class, 'Rest_Controller') === 0) {
@include_once( APPPATH . 'core/' . $class . EXT );
return;
}
};
spl_autoload_register($autoload);https://stackoverflow.com/questions/59045274
复制相似问题