Break

Sample Code

<?php    

// defines the for loop   

for ($a = 0; $a < 10; $a++) {  

  if ($a == 7) {  

    break; /* Break the loop when condition is true. */  

  }  

  echo "Number: $a <br>";  

}  

echo " Terminate the loop at $a number";  

?>  

Output

Continue

Sample Code

<?php    

// defines the for loop   

for ($a = 0; $a < 7; $a++) {  

  if ($a == 5) {  

  echo " Skipped number is $a <br>"; // prints the skipped number.  

    continue; /* It skips the defined statement if the condition is true. */  

  

  }  

  echo "Number is: $a <br>";  

}  

?>

 Output

Categorized in:

PHP

Tagged in:

, , , , , , , , , , , , , ,

Share Article:

Leave a Reply

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock