Bird
0
0

Which of the following is the correct syntax to access a class constant named STATUS inside the same class?

easy📝 Syntax Q3 of 15
PHP - Classes and Objects
Which of the following is the correct syntax to access a class constant named STATUS inside the same class?
A$this->STATUS
Bstatic->STATUS
Cself::STATUS
Dthis::STATUS
Step-by-Step Solution
Solution:
  1. Step 1: Recall how to access constants inside the same class

    Inside the class, constants are accessed using self::CONSTANT_NAME.
  2. Step 2: Check other options for syntax errors

    $this-> is for properties, static-> is invalid, this:: is invalid syntax.
  3. Final Answer:

    self::STATUS -> Option C
  4. Quick Check:

    Inside class constant access = self:: [OK]
Quick Trick: Use self::CONSTANT inside class to access constants [OK]
Common Mistakes:
  • Using $this-> for constants
  • Using invalid static-> syntax
  • Writing this:: instead of self::

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes