A for loop is a loop that can be infinite, which means the loop runs infinitely inside the curly braces. That happens when the condition is not declared. If you include a break statement, the loop will exit; otherwise, you must manually stop or interrupt the program.
Syntax:
for(;;) {
}
Example:
<?php
// Infinite loop using for loop..
for(;;) { // This loop will run infinitely if you do not use the break.
Echo "Learning PHP loops is fun! <br>";
break; // The loop will exit here because of this break statement
}
?>
Output:
Learning PHP loops is fun!
