Bird
0
0

Find the error in this PHP code snippet:

medium📝 Debug Q6 of 15
PHP - Loops

Find the error in this PHP code snippet:

for ($i = 0; $i < 3; $i++) {
    for ($j = 0; $j < 3; $j++) {
        if ($j == 1) continue(2);
        echo "$i$j ";
    }
}
AUsing continue with parentheses is invalid syntax
BThe loops have wrong conditions
Ccontinue(2) should be break(2)
DNo error, code runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of continue with levels

    PHP does not allow parentheses with continue statement levels; continue(2) is invalid.
  2. Step 2: Identify correct syntax

    The correct syntax is continue 2; without parentheses.
  3. Final Answer:

    Using continue with parentheses is invalid syntax -> Option A
  4. Quick Check:

    continue with parentheses = syntax error [OK]
Quick Trick: Use continue n; without parentheses for levels [OK]
Common Mistakes:
  • Using continue(2) with parentheses
  • Confusing continue with break
  • Assuming code runs without error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes