1. 简单循环语句while
while(<condition>)
{
<action block>
}
do
{
<action block>
}
while(<condition>)
2. for循环
for(<initializer>;<exit condition>;<step action>)
{
<action>
}
初始化和步进值为可选
3. 遍历集合的循环语句 for each Loop
foreach($item in $collection)
{
<action>
}
4. 强制退出循环使用break语句;反复遍历一个集合并操作其中的大多数对象,可以使用continue语句。break所在的程序段的条件满足的情况下将会退出整个循环,而continue语句块的条件成立时将会跳过当前循环,继续下一个循环。