Bird
0
0

Which of the following variable names is not allowed in PHP?

easy📝 Conceptual Q1 of 15
PHP - Variables and Data Types
Which of the following variable names is not allowed in PHP?
A$_userName
B$2ndUser
C$user_name
D$userName123
Step-by-Step Solution
Solution:
  1. Step 1: Understand PHP variable naming rules

    PHP variable names must start with a letter or underscore, not a number.
  2. Step 2: Check each option

    $2ndUser starts with '2', which is invalid. Others start with letters or underscore.
  3. Final Answer:

    $2ndUser is invalid because it starts with a number. -> Option B
  4. Quick Check:

    Variable names cannot start with numbers = C [OK]
Quick Trick: Variable names must start with letter or underscore, never a number [OK]
Common Mistakes:
  • Starting variable names with digits
  • Using spaces in variable names
  • Starting with special characters other than underscore

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes