gpt4 book ai didi

php - PHP中break和continue之间的区别?

转载 作者:IT老高 更新时间:2023-10-28 11:44:13 26 4
gpt4 key购买 nike

break 和有什么区别?和 continue在 PHP 中?

最佳答案

break 完全结束一个循环,continue 只是缩短当前迭代并进入下一个迭代。

while ($foo) {   <--------------------┐
continue; --- goes back here --┘
break; ----- jumps here ----┐
} |
<--------------------┘

这样使用:

while ($droid = searchDroids()) {
if ($droid != $theDroidYoureLookingFor) {
continue; // ..the search with the next droid
}

$foundDroidYoureLookingFor = true;
break; // ..off the search
}

关于php - PHP中break和continue之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4364757/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com