Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在将生产代码从PHP5.3to迁移到PHP7.1,代码break 2;在 if 条件内嵌套了两级 while 循环,我得到以下错误:
PHP5.3
PHP7.1
break 2;
PHP 致命错误:无法“打破”2 个级别
为什么 PHP7.1 中删除了两级中断,它的替代解决方案可能是什么?
您可以通过 change 解决此问题:
经过:
break;
您进入一个循环而不是两个嵌套循环。这就是为什么你不能“打破 2”(因为 2 表示你在一个嵌套循环中)。出现该错误是因为 PHP7 比以前的版本更严格。
注意:您不能从 if 语句中“中断”。您只能从循环中中断。