PHP Break and Continue statement

PHP Break and Continue statement


            

Break Statement:

The break statement can also be used to jump out of a loop.PHP break statement can terminate PHP loop statements immediately. When for loop, foreach loop or while loop faces break keyword, it terminates its loop execution and program control goes to next statement. So, we should be careful enough to place break keyword within a PHP conditional statement. Otherwise PHP loop statements will not be executed more than once. 

For Example:

 

 

Continue Statement:

PHP continue keyword is used to skip the remaining part of the code and program control goes to the condition-checker part of the loop.PHP continue statement starts a new loop without executing current loop body. When a loop finds continue keyword, it stops the body execution and restarts the loop. So, we should be careful to use PHP continue inside a conditional statement otherwise loop body will never be executed.

For Example :