在emlog装置界面涌现Deprecated已弃用函数提醒,“Deprecated: __autoload() is deprecated, use spl_autoload_register() instead in ..\include\lib\function.base.php on line 7”,这是因为服务器php运用的是php7,而__autoload()函数在php7版本已被弃用,解决要领是运用低版本的php(如php5.5等),或许替代该函数。
解决要领
要领一:
运用php7以下版本,如php 5.4、php 5.5等
要领二:
进入提醒的途径include\lib\function.base.php,编辑function.base.php文件,找到第7行代码,即__autoload()函数,函数代码以下:
123456789101112 | function __autoload($class) {$class = strtolower($class);if (file_exists(EMLOG_ROOT . '/include/model/' . $class . '.php')) {require_once(EMLOG_ROOT . '/include/model/' . $class . '.php');} elseif (file_exists(EMLOG_ROOT . '/include/lib/' . $class . '.php')) {require_once(EMLOG_ROOT . '/include/lib/' . $class . '.php');} elseif (file_exists(EMLOG_ROOT . '/include/controller/' . $class . '.php')) {require_once(EMLOG_ROOT . '/include/controller/' . $class . '.php');} else {emMsg($class . '加载失利。');}} |
将其修改成以下代码
123456789101112 | spl_autoload_register(function($class) {$class = strtolower($class);if (file_exists(EMLOG_ROOT . '/include/model/' . $class . '.php')) {require_once(EMLOG_ROOT . '/include/model/' . $class . '.php');} elseif (file_exists(EMLOG_ROOT . '/include/lib/' . $class . '.php')) {require_once(EMLOG_ROOT . '/include/lib/' . $class . '.php');} elseif (file_exists(EMLOG_ROOT . '/include/controller/' . $class . '.php')) {require_once(EMLOG_ROOT . '/include/controller/' . $class . '.php');} else {emMsg($class . '加载失利。');}}); |
或
12345678910111213 | function autoload($class) {$class = strtolower($class);if (file_exists(EMLOG_ROOT . '/include/model/' . $class . '.php')) {require_once(EMLOG_ROOT . '/include/model/' . $class . '.php');} elseif (file_exists(EMLOG_ROOT . '/include/lib/' . $class . '.php')) {require_once(EMLOG_ROOT . '/include/lib/' . $class . '.php');} elseif (file_exists(EMLOG_ROOT . '/include/controller/' . $class . '.php')) {require_once(EMLOG_ROOT . '/include/controller/' . $class . '.php');} else {emMsg($class . '加载失利。');}}spl_autoload_register('autoload'); |
上面代码二选一,保留文件后,从新翻开装置界面,deprecated提醒消逝。
PS:上面两个代码的区别是:一个是匿名函数引入,一个是把函数封装,都可以运用。
Emlog 5.3.1现在并不支撑php7+版本,背面博客吧会分享在php7下装置运用emlog 5.3.x版本的教程。
原文地点:https://www.boke8.net/emlog-deprecated-autoload.html

评论列表