The continue jump statement is used to skip statements that specify conditions in this loop, and to continue executing other loop statements. The following article mainly introduce to you in PHP with continue skip this cycle of the remainder of the code of a note, the content of the text in the basis of comparison, the need for friends can refer to the following to see together.
Objective
As we all know, continue in PHP is used to skip the remaining code in this loop and start the next loop when the condition evaluates to True. It must be noted that the use of continue to use ";" To separate other code, or it could cause an error!
Continue usage:
<?phpfor ($n = 0; $n < 5; $n + +) {if ($n = = 2) continue; echo "$n \ n";}? >
Output Result:
0 1 3 4
Obviously, when $n equals 2, the output is skipped, just in line with our wishes. If the semicolon is missing, you will get an error!
The wrong code:
<?phpfor ($n = 0; $n < 5; $n + +) {if ($n = = 2) continue echo "$n \ n";}? >
Error message:
Parse error:syntax error, unexpected ' echo ' (T_echo) in D:\phpStudy\WWW\demo\fun\continue.php on line 5
So note: We use the continue must be careful not to miss the semicolon!