Bird
0
0

Identify the error in this PHP code snippet:

medium📝 Debug Q6 of 15
PHP - Variables and Data Types
Identify the error in this PHP code snippet:
$1var = 100;
echo $1var;
AVariable names cannot contain letters
BMissing semicolon after assignment
CDollar sign ($) is missing
DVariable names cannot start with a number
Step-by-Step Solution
Solution:
  1. Step 1: Check variable naming rules

    PHP variable names must start with a letter or underscore, not a number.
  2. Step 2: Analyze the code

    $1var starts with a number '1', which is invalid.
  3. Final Answer:

    Variable names cannot start with a number -> Option D
  4. Quick Check:

    Variable name rules = start with letter or _ [OK]
Quick Trick: Variable names must start with letter or underscore [OK]
Common Mistakes:
  • Starting variable name with number
  • Ignoring variable naming rules
  • Assuming $ is optional

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes