【问题标题】:Deprecated: Non-static method SmartyPaginate::connect() should not be called statically不推荐使用:不应静态调用非静态方法 SmartyPaginate::connect()
【发布时间】:2017-12-24 03:03:24
【问题描述】:

我正在为 SMARTY 模板使用 SmartyPaginate 插件,它从这个插件中抛出 6-7 个相同类型的错误。当我升级到 PHP 7 时出现了所有错误。虽然我可以禁用错误显示,但我真的很想永久解决这个问题。

已弃用:不应在第 58 行的 libs\plugins\function.paginate_prev.php 中静态调用非静态方法 SmartyPaginate::getCurrentIndex()

引发错误的代码。

if (SmartyPaginate::getCurrentIndex($_id) === false) {
    $smarty->trigger_error("paginate_prev: total was not set");
    return;        
}

【问题讨论】:

  • 我确定您使用的是 SmartyPaginate1.6 而不是 smart-3 ... SmartyPaginate1.6 已经是一个非常过时的脚本,我建议您升级模板系统以使用 php7 .
  • 我正在使用最新的 Smarty。这是基于 Smarty 1.6 的插件的一些错误。没有最新的 smarty 分页插件可用。
  • 所以插件是过时/过时的。解决办法是:改变技术或使用旧版本的PHP。
  • 我能够解决大部分错误。我很难将一种特定类型的行转换为 PHP 7 兼容代码。我现在更新了描述。

标签: smarty php-7 smarty3


【解决方案1】:

我解决了所有静态错误。我做了以下解决方案。 旧代码

if (SmartyPaginate::getCurrentIndex($_id) === false) {
    $smarty->trigger_error("paginate_prev: total was not set");
    return;        
}

新代码

if ((new SmartyPaginate)->getCurrentIndex($_id) === false) {
    $smarty->trigger_error("paginate_next: total was not set");
    return;        
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-08
    • 2013-11-10
    • 1970-01-01
    • 1970-01-01
    • 2012-08-16
    • 2015-01-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多