The difference between the break and continue process control commands in PHP is analyzed. The following example shows that break is used to jump out of the current execution cycle and stop executing the loop. Copy the code as follows :? Php $ i0; while ($ i7) {if ($ arr [$ I] stop) {break example below
Break is used to jump out of the current execution cycle and stop executing the loop.
The code is as follows:
$ I = 0;
While ($ I <7 ){
If ($ arr [$ I] = "stop "){
Break;
}
$ I ++;
}
?>
Continue immediately stops the current execution cycle, returns to the condition judgment of the loop, and continues the next loop.
The code is as follows:
While (list ($ key, $ value) = each ($ arr )){
If ($ key = "zhoz") {// if the queried object value is zhoz, this record will not be displayed.
Continue;
}
Do_something ($ value );
}
// Example 2
Foreach ($ list as $ temp ){
If ($ temp-> value = "zhoz "){
Continue; // if the queried object value is zhoz, this record will not be displayed.
}
Do_list; // records in the array are displayed here.
}
?>
Note: The goto loop command cannot be used in PHP.
Break is used to jump out of the current execution cycle and stop executing the loop. The code is as follows :? Php $ I = 0; while ($ I 7) {if ($ arr [$ I] = "stop") {break...