In PHP, what is the difference between break and continue statements?

  • The break statement terminates the loop, while continue skips to the next iteration
  • The break statement resumes the next iteration, while continue terminates the loop
  • The break statement is used in loops, while continue is used in switch statements
  • The break statement is used to skip code, while continue is used to terminate the loop
The correct option is: "The break statement terminates the loop, while continue skips to the next iteration." The break statement is used to exit a loop entirely, while the continue statement skips the remaining code in the current iteration and moves on to the next iteration of the loop. They serve different purposes in controlling the flow of a loop. Learn more: https://www.php.net/manual/en/control-structures.break.php, https://www.php.net/manual/en/control-structures.continue.php
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *