【问题标题】:**Strict Standards Only variables should be passed by reference**严格标准仅变量应通过引用传递
【发布时间】:2017-12-28 12:32:11
【问题描述】:

我在运行我的代码时遇到了这个错误 我无法理解那个东西的错误,有什么建议吗?

严格标准:只有变量应该在 /home/kea/newalarab/cmets/cmets/src/Comments/Comments.php 第 552 行通过引用传递

严格的标准:只有变量应该在 /home/kea/newalarab/cmets/cmets/src/Comments/Comments.php 第 563 行通过引用传递

    public function authUser($attribute = null)
{
    return reset($this['events']->fire('auth.user', $attribute)); //line 552
}

public function adminCheck()
{
    return reset($this['events']->fire('admin.check')) === true; //line 563
}

【问题讨论】:

  • 'auth.user''admin.check'放入变量中,并将这些变量传递给函数fire(),因为fire()很可能被声明为fire(&$par, $attr)

标签: php


【解决方案1】:

您可能会发现 reset() 被定义为...

reset( &$value ) {}

期望值通过引用传递。当您调用它时,您需要传递一个实际变量,而不是直接从函数传递返回值。所以...

public function authUser($attribute = null)
{
    $value = $this['events']->fire('auth.user', $attribute);
    return reset($value); //line 552
}

public function adminCheck()
{
    $value = $this['events']->fire('admin.check');
    return reset($value) === true; //line 563
}

这也可能是 fire() 以类似方式声明的结果,您需要确定是哪一个导致了问题并按上述方式进行修改。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-21
    • 1970-01-01
    • 2014-07-13
    • 1970-01-01
    相关资源
    最近更新 更多