PHP – break statement

We have used the “break;” keyword in our switch statement to stop the execution of the program once the match the condition.

So the PHP break statement will terminate the program immediately and come out of the loop without wasting any more time in execution. So the main benefit of break; statement is to make the program execution faster.

So we can  use break; keyword in loops like for loop, while loop, do…while loop, foreach loop and switch statement.

Example 

 

Leave a Reply

Your email address will not be published.