【问题标题】:Opening parenthesis of a multi-line function call must be the last content多行函数调用的左括号必须是最后的内容
【发布时间】:2019-11-25 16:08:53
【问题描述】:

我收到了与下面代码中的第 7 行相关的 PHP 代码嗅探器错误。

将下一个方括号移动到这一行似乎会引入新的错误。我有点不清楚如何解决这个问题。

多行函数调用的左括号必须是最后一个内容

if ($cms_user) {
    array_push($buttons, [
        'id' => 5,
        'name' => 'Home Page'
    ]);
} elseif ($public) {
    array_push($buttons,
        [
            'id' => 3,
            'name' => 'About Us'
        ],
        [
            'id' => 11,
            'name' => 'Reflection',
        ],
        [
            'id' => 2,
            'name' => 'Contact Us',
        ]
    );
}

【问题讨论】:

标签: php


【解决方案1】:

多行函数调用的左括号必须是最后一个 内容

如果你有一个跨越多行的函数,那么函数调用的开头括号必须是第一行的最后一件事。我通常会这样做:

array_push(
    $buttons,
    [
        'id' => 5,
        'name' => 'Home Page'
    ]
);

【讨论】:

  • 完美,解决了!谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-06-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-16
相关资源
最近更新 更多