Bird
0
0

What does the new keyword do in PHP?

easy📝 Conceptual Q11 of 15
PHP - Classes and Objects

What does the new keyword do in PHP?

AIt deletes an existing object.
BIt defines a new class.
CIt calls a function inside a class.
DIt creates a new instance of a class (an object).
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of new

    The new keyword is used to create an object from a class blueprint.
  2. Step 2: Differentiate from other keywords

    It does not delete objects, call functions, or define classes; it only creates objects.
  3. Final Answer:

    It creates a new instance of a class (an object). -> Option D
  4. Quick Check:

    new creates objects [OK]
Quick Trick: Remember: new = create object from class [OK]
Common Mistakes:
  • Thinking new deletes objects
  • Confusing new with function calls
  • Believing new defines classes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes