Ec (2); * $ i5; & nbsp; copy the code $ sum0; for ($ j0; $ j & lt; 10; $ j ++) {& nbsp; if ($ j $ I) & nbsp ;{& nbsp; & nbsp; break; & nbsp ;}& nbsp; else & nbsp ;{& nbsp; & nbsp; $ sum + $ j; & nbsp;} script ec (2); script
*/
$ I = 5;
The Code is as follows: |
|
$ Sum = 0; For ($ j = 0; $ j <= 10; $ j ++) { If ($ j = $ I) { Break; } Else { $ Sum + = $ j; } } |
Echo $ sum; // 10
The Code is as follows: |
|
$ ContinueSum = 0; For ($ I = 0; $ I <= 10; $ I ++) { If ($ I = 5) { Continue; } Else { $ ContinueSum + = $ I; } } |
The Code is as follows: |
|
Echo $ continueSum; // 50 $ A = 2;
If ($ a = 2) { Return $ s = 8; } Else { Return $ s = 9; }
|
Echo $ s; // nothing. Let's write it as a function.
Echo sv ($ a); // lost 10
The Code is as follows: |
|
Function sv ($) { If ($ a = 2) { Return 10; } Else { Return 11; } }
|
/*
Summary:
Continue jumps out of the current loop and enters the next loop
The break jumps out of the current loop and executes other code.
The return operation is terminated, and no code after the return operation is executed.
The original article on this site is reprinted with the source www.111cn.net/phper/php.html
*/