Bird
0
0

Find the error in this PHP code:

medium📝 Debug Q6 of 15
PHP - Basics and Execution Model
Find the error in this PHP code:
<?php
$x = 10
$y = 20;
echo $x + $y;
?>
AWrong variable names
BEcho statement syntax error
CMissing semicolon after $x = 10
DNo error
Step-by-Step Solution
Solution:
  1. Step 1: Check each line for syntax errors

    The line $x = 10 is missing a semicolon at the end.
  2. Step 2: Confirm other lines are correct

    $y = 20; and echo statement are correct.
  3. Final Answer:

    Missing semicolon after $x = 10 -> Option C
  4. Quick Check:

    PHP statements end with ; [OK]
Quick Trick: Always end PHP statements with a semicolon [OK]
Common Mistakes:
  • Omitting semicolons
  • Using wrong variable names
  • Incorrect echo syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes