You are writing a PHP script and you want to stop the execution of a loop once a certain condition is met. How would you do this using break?

  • Use the break statement to terminate the current loop.
  • Use the continue statement to skip the rest of the current iteration.
  • Use the exit statement to stop the script execution.
  • Use the return statement to exit the loop and return a value.
The correct option is: "Use the break statement to terminate the current loop." The break statement in PHP is used to stop the execution of the current loop and move to the line immediately following the loop. It allows you to prematurely exit the loop when a certain condition is met. Learn more: https://www.php.net/manual/en/control-structures.break.php
Add your answer
Loading...

Leave a comment

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