【问题标题】:Strict Standards: Only variables should be passed by reference in... on line 777严格的标准:只有变量应该在第 777 行通过引用传递...
【发布时间】:2023-03-06 10:41:01
【问题描述】:

我的网站的某些页面出现错误:

严格标准:只有变量才能通过引用传递 /home/... 在第 777 行

这是这一行:

$arg_list = $this->_compile_arg_list('function', $tag_command, $attrs, $_cache_attrs='');

我应该改变什么? 任何帮助表示赞赏。

问题解决了,谢谢。

【问题讨论】:

  • $_cache_attrs='' 看起来很可疑,但我从未使用过此功能。
  • 欢迎来到 Stack Overflow。您可以使用Code Sample {} 工具栏按钮格式化源代码——这次我已经为您完成了。
  • 您可能想要添加被调用方法的签名。然而,给你带来麻烦的是第一个或第四个参数。
  • $_cache_attrs='' 很可能是一个简单的错字。
  • 这是 PHP 5.4+ 中新出现的吗?我们都非常喜欢 PHP 升级...

标签: php


【解决方案1】:
<?php

function foo(&$a){
}

$a = 33;
foo($a); // OK

foo(33); // Fatal error: Only variables can be passed by reference

所以相应地修复你的代码。

【讨论】:

    【解决方案2】:

    你不能在函数调用中通过引用来赋值,如果你需要一个默认行为,你可以在函数本身或调用它之前设置它。

    $_cache_attrs = '';
    $arg_list = $this->_compile_arg_list('function', $tag_command, $attrs, $_cache_attrs);
    

    【讨论】:

    • @user3062493 如果它有效并且适合您的问题,请随时接受答案
    【解决方案3】:

    也许'function' 应该是可调用的..

    $function = function() { };
    $arg_list = $this->_compile_arg_list(
        $function,
        $tag_command,
        $attrs,
        $_cache_attrs=''
    );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-13
      • 1970-01-01
      • 1970-01-01
      • 2018-10-08
      • 2013-07-24
      • 2016-01-12
      • 2014-11-01
      相关资源
      最近更新 更多