PHP break, continue and goto Statements

PHP break and continue statements are used to dominate or control PHP loop statements and PHP goto statement is used to jump one execution label to another execution label. There is no alternative to control PHP for loop, while loop and foreach loop without PHP break and PHP continue statements. So, PHP programmer should learn PHP break and continue statements deeply otherwise he/she cannot be expert enough on PHP loop statements. In my previous article I explained PHP loop statements and in this article I will discuss PHP break, continue and goto statements elaborately. break Statement in PHP 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.     PHP break Statement Example The following program is a tiny example of PHP while break and the break keyword is being used within conditional statement. Output 0 1 2 3 4 From the above program we can see that while loop is being executed only five […]

Continue reading