break case, continue case
break case skips the remaining code till the end of the switch or check block. Even the else statement will be skipped.
continue case skips the remaining code inside that case block, then continues checking the next case and else statements.
Indirect parameter passing is disabled
0
for (a[] = 1, a[] <= 5, a[]++)
{
print ( "Switch Loop ",a[], ": " );
switch( a [] )
{
case (1)
{
print("Case 1; ");
}
case (2)
{
print("Case 2; ");
continue case;
}
case (3)
{
print("Case 3; ");
break case;
}
case (2)
{
print("Case 2 again; ");
}
case (1,2,3,4)
{
print("Case 4; ");
}
else
{
print("Else 1; ");
}
else
{
print("Else 2; ");
}
}
echo;
}
for (a[] = 1, a[] <= 5, a[]++)
{
print ( "Check Loop ",a[], ": " );
check( a [] )
{
case (1)
{
print("Case 1; ");
}
case (2)
{
print("Case 2; ");
continue case;
}
case (3)
{
print("Case 3; ");
break case;
}
case (2)
{
print("Case 2 again; ");
}
case (1,2,3,4)
{
print("Case 4; ");
}
else
{
print("Else 1; ");
}
else
{
print("Else 2; ");
}
}
echo;
}
Switch Loop 1: Case 1; Else 2;
Switch Loop 2: Case 2; Else 2;
Switch Loop 3: Case 3;
Switch Loop 4: Case 4; Else 2;
Switch Loop 5: Else 1; Else 2;
Check Loop 1: Case 1; Case 4; Else 2;
Check Loop 2: Case 2; Case 2 again; Case 4; Else 2;
Check Loop 3: Case 3;
Check Loop 4: Case 4; Else 2;
Check Loop 5: Else 1; Else 2;