Difference in php continue break exit return of

in php circulates for foreache while do {} whlie these types.

1、continue

continue in the loop structure is used, the control program to abandon this cycle continue;

After the statement, and turn into the next cycle.

continue out of the loop structure itself is not just give up this cycle.

Note: continue if used in a non-loop structure (if switch) would cause an error.

2、break

Break out of the current action is the syntax structure, break statement with a parameter n, the number of layers out.

3、exit

exit end of the program execution, can be used in any position.

4、return

statement is used to end a return code and a return parameter.

If used in the main program, the main program will immediately stop the execution.

E.g:

. 1 <? PHP
 2  for ( $ I = 1000; $ I > =. 1; $ I - ) {
 . 3  IF ( sqrt ( $ I )> = 30 ) {
 . 4      echo  $ I "</br>." ;
 . 5  }
 . 6  the else {
 . 7      return ;
 . 8  }
 . 9  }
 10  
. 11  echo "Bank will not be output";

 

Link: https: //mp.weixin.qq.com/s/yYeG5P7qtT07Pgq_u5rRTg

Guess you like

Origin www.cnblogs.com/clubs/p/11873907.html