在 php 7.3 中 switch 语句中使用 continue

在 php 7.3 中 switch 语句中使用 continue

在 php 7.3 的 switch 中使用 continue 会出现警告。[1] [2] [3]

while ($foo) {
    switch ($bar) {
        case "baz":
            continue; // In PHP: Behaves like "break;"
                      // In C:   Behaves like "continue 2;"
    }
}

最好的方式是把 continue 改为 continue 2 或 break


  1. https://wiki.php.net/rfc/continue_on_switch_deprecation ↩︎

  2. https://github.com/aces/Loris/issues/4037 ↩︎

  3. https://github.com/squizlabs/PHP_CodeSniffer/pull/2086 ↩︎

posted on 2018-12-17 08:29  建伟F4nniu  阅读(2964)  评论(0编辑  收藏  举报

导航