1. Break: indicates the process of stopping the current for, while, do... while, and switch. A number can be provided later to indicate the layer to which the switch flow is redirected.
For example:
<? PHP
$ I = 0;
While (++ $ I ){
Switch ($ I ){
Case 4:
Echo "quit to 4. <br> ";
Break; // jump out of the switch statement
Case 9:
Echo "quto to 9. <br/> ";
Break 2; // There is a 2-layer hop. The number in the while loop cannot exceed the actual number of layers. If it is written as break 3, the system reports an error.
Default:
Break;
}
}
Echo 'over! & Nbsp; $ I = '. $ I;
?>
Result:
Quit to 4.
Quto to 9.
Over! $ I = 9
2. Continue statement:Jump out of the remainder of this loopCodeAnd determine the next cycle when the condition is true
<? PHP
For ($ I = 0; $ I <13; $ I ++ ){
If ($ I = 5 ){
Continue; // jump out of the remaining code in this loop and judge whether this condition is true for the next loop
}
Echo '$ I ='. $ I. "<br/> ";
}
Echo "over ";
?>
Result:
$ I = 0
$ I = 1
$ I = 2
$ I = 3
$ I = 4
$ I = 6
$ I = 7
$ I = 8
$ I = 9
$ I = 10
$ I = 11
$ I = 12
Over
You can also add numbers after continue:
<? PHP
For ($ I = 0; $ I <2;$ I ++ ){//@
For ($ j = 1; $ j <4; $ J ++ ){
If ($ J = 2 ){
Continue 2; // After jumping out of the Layer 2 loop, execute $ I ++ //@
}
Echo '$ I ='. $ I. '$ J ='. $ J. '<br/> ';
}
}
Echo "over ";
?>
Result:
$ I = 0 $ j = 1
$ I = 1 $ j = 1
Over
3. GOTO statement: Jump can only be performed in the same file or scope
Syntax: goto tag;
Tags:
//... Statement
<? PHP
Goto;
Echo "AA ";
A:
Echo "BB ";
?>
Output: bb