Bird
0
0

Why does PHP require a dollar sign ($) before variable names?

hard📝 Conceptual Q10 of 15
PHP - Variables and Data Types
Why does PHP require a dollar sign ($) before variable names?
ATo indicate the variable type explicitly
BTo mark variables as global only
CTo distinguish variables from constants and keywords
DTo make variable names case-insensitive
Step-by-Step Solution
Solution:
  1. Step 1: Understand PHP variable syntax purpose

    The $ sign helps PHP identify variables clearly, separating them from constants, functions, and keywords.
  2. Step 2: Analyze options

    Only To distinguish variables from constants and keywords correctly explains the purpose of the $ sign. PHP does not use $ to indicate type, scope, or case sensitivity.
  3. Final Answer:

    To distinguish variables from constants and keywords -> Option C
  4. Quick Check:

    $ sign purpose = distinguish variables [OK]
Quick Trick: Dollar sign marks variables, not types or scope [OK]
Common Mistakes:
  • Thinking $ shows type
  • Assuming $ means global
  • Believing $ affects case sensitivity

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes