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
Loading...
Related Quiz
- In your PHP script, you have a loop inside another loop. You want to stop the execution of both loops once a certain condition is met. How would you do this using break?
- You have a floating-point number in your PHP script and you need to round it to the nearest integer. How would you do this?
- You are writing a PHP script and you need to define a trait. How would you do this?
- What is the purpose of the mysqli_connect() function in PHP?
- A common practice in PHP forms is to validate user inputs such as email and URL to prevent ______.