【问题标题】:Only variables should be passed by reference in php [duplicate]只有变量应该在php中通过引用传递[重复]
【发布时间】:2015-06-09 09:15:32
【问题描述】:

我有以下代码:

    $_SESSION['aParties'] = time();
    $aParties[] = $_SESSION['aParties'];
    error_log(print_r($aParties,true), 3, "/var/tmp/error.log");
    $first = reset(ksort($aParties));

数组aParties是这样的:

Array
(
  [0] => 1433841062
)

但我得到了错误:

'Only variables should be passed by reference in the method ksort' 

请帮帮我!提前谢谢

【问题讨论】:

    标签: php pass-by-reference php-5.3


    【解决方案1】:

    你需要这样做

    ksort($aParties);
    $first = reset($aParties);
    

    注意:函数调用没有参考符号 - 仅在函数定义上。仅函数定义就足以通过引用正确传递参数。

    Check Docs

    【讨论】:

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