Bird
0
0

Why does break 0; cause an error in PHP when used inside nested loops?

hard📝 Conceptual Q10 of 15
PHP - Loops

Why does break 0; cause an error in PHP when used inside nested loops?

ABecause break 0; exits all loops silently.
BBecause break level must be at least 1 to exit loops.
CBecause break 0; is treated as continue.
DBecause break 0; restarts the loop.
Step-by-Step Solution
Solution:
  1. Step 1: Understand break level rules

    Break level specifies how many loops to exit; it must be a positive integer.
  2. Step 2: Why break 0; is invalid

    Using break 0; is invalid because it means exit zero loops, which makes no sense and causes an error.
  3. Final Answer:

    Because break level must be at least 1 to exit loops. -> Option B
  4. Quick Check:

    Break level ≥ 1 required, break 0 invalid [OK]
Quick Trick: Break level must be 1 or more, zero is invalid [OK]
Common Mistakes:
  • Using break 0; expecting no effect
  • Confusing break 0; with continue
  • Assuming break 0; restarts loop

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes