discuz提示Deprecated: __autoload() is deprecated, use spl_autoload_register() instead in /www/wwwroot/nextgod/source/class [复制链接]

moqu8 2018-7-29

2725 0
discuz提示Deprecated: __autoload() is deprecated, use spl_autoload_register() instead in /www/wwwroot/nextgod/source/class/class_core.php on line 27解决方案:
84295b5daf19dfee8.png
Discuz! PHP Deprecated: __autoload() is deprecated, use spl_autoload_register() instead in source\class\class_core.php on line 27
PHP 7.2开始不主张使用function __autoload(){}来自动加载类文件。
__autoload() been DEPRECATED as of PHP 7.2.0. Relying on this feature is highly discouraged.
请使用spl_autoload_register($callable)来替代__autoload()自动加载函数。其中参数$callable是一个自定义函数。自定义函数的参数为需要加载的类。其他用法和使用__autoload()自动加载函数一样。
spl_autoload_register()可以注册多个自动加载函数,而使用自动加载函数__autoload()自动加载类时只能写一个__autoload()函数。
Discuz!使用传统的__autoload()来自动加载类文件,在PHP 7.2中运行需要改为spl_autoload_register()。

  1. 找到文件source\class\class_core.php,用文件编辑软件打开,搜索
if(function_exists('spl_autoload_register')) {
spl_autoload_register(array('core', 'autoload'));
} else {
function __autoload($class) {
return core::autoload($class);
}
}
修改为:


if(function_exists('spl_autoload_register')) {
spl_autoload_register(array('core', 'autoload'));
}
保存即可!
其实这个if判断也是没有必要的,因为从PHP 5.1开始就已经支持spl_autoload_register()了。


最新回复 (0)
返回
支持中心
邮箱:winkill2012@qqcom
新站优化中!部分功能尚未完善,敬请谅解!
支持中心