discuz提示Deprecated: __autoload() is deprecated, use spl_autoload_register() instead in /www/wwwroot/nextgod/source/class/class_core.php on line 27解决方案:

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()。
- 找到文件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()了。
历史资源提醒--必看
该页面资源/教程来自原魔趣吧历史资源转移,因发布历史久远,部分资源/教程可能已失效或无法在最新版程序中安装使用!DZ资源建议在Discuz3.4及以下版本使用,PHP版本建议5.6。资源仅提供做代码研究学习使用!
因改版,部分贴内链接将无法正常跳转,如链接失效或未正常跳转,请利用站内搜索功能搜索资源名称获取对应资源!