Bird
0
0

What is the correct way to name a class in PHP?

easy📝 Conceptual Q2 of 15
PHP - Classes and Objects
What is the correct way to name a class in PHP?
AUse spaces between words
BStart with a letter or underscore
CStart with a number
DUse special characters like @ or #
Step-by-Step Solution
Solution:
  1. Step 1: Recall PHP class naming rules

    Class names must start with a letter or underscore and cannot contain spaces or special characters.
  2. Step 2: Match the correct naming rule

    Start with a letter or underscore correctly states the rule: start with a letter or underscore.
  3. Final Answer:

    Start with a letter or underscore -> Option B
  4. Quick Check:

    Class naming rule = start with letter or underscore [OK]
Quick Trick: Class names start with letter or underscore, no spaces [OK]
Common Mistakes:
  • Starting class name with a number
  • Using spaces in class names
  • Including special characters in names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes