近期把PHP升级到了最新稳定版本7.2.8。访问博客首页提示了两个Deprecated错误, 关于函数create_function()和__autoload(),错误信息以及对应的代码如下
错误一:
// Deprecated: Function create_function() is deprecated in /var/www/html/niliu/wp-includes/pomo/translations.php on line 208
/**
* Makes a function, which will return the right translation index, according to the
* plural forms header
* @param int $nplurals
* @param string $expression
*/
function make_plural_form_function($nplurals, $expression) {
$expression = str_replace('n', '$n', $expression);
$func_body = "
\$index = (int)($expression);
return (\$index < $nplurals)? \$index : $nplurals - 1;";
return create_function('$n', $func_body);
}
错误二:
// Deprecated: __autoload() is deprecated, use spl_autoload_register() inst