【问题标题】:CUTENEWS.RU - Strict Standards: Only variables should be passed by reference inCUTNEWS.RU - 严格标准:只有变量应该通过引用传递
【发布时间】:2020-06-01 12:49:30
【问题描述】:

这段代码有问题,有什么帮助吗?

$var = reset($sql -> select(array(
  'table' => 'news',
  'join' => array('table' => 'story', 'where' => 'id = post_id'),
  'where' => array("id = $id", 'or', "url = $id")
)));

错误:

Strict Standards: Only variables should be passed by reference in

$query = reset(  
    $sql->select(array(  
        'table'     => 'news',  
        'where'     => $where  
)));   
Strict Standards: Only variables should be passed by reference in

【问题讨论】:

  • 你使用哪个库? $sql是什么类型的?

标签: php


【解决方案1】:

看看here

reset() 函数正在等待变量引用,而不是您传递给它一个函数结果
欲了解更多信息,请参阅php reset docs

您可以,提取函数的结果,然后将其传递给reset(),如下所示。

$select = $sql -> select(array(
  'table' => 'news',
  'join' => array('table' => 'story', 'where' => 'id = post_id'),
  'where' => array("id = $id", 'or', "url = $id")
))
$var = reset($select);

然后是另一个:

$select1 = $sql->select(array(
             'table'      => 'news',
             'where'      => $where
            ));
$query = reset($select1);

PHP 现场演示

【讨论】:

    猜你喜欢
    • 2014-07-13
    • 1970-01-01
    • 1970-01-01
    • 2016-01-12
    • 2014-11-01
    • 2015-05-27
    • 2016-10-05
    相关资源
    最近更新 更多