Bird
0
0

Which keyword is used in PHP to specify which trait method to use when two traits have conflicting method names?

easy📝 Conceptual Q2 of 15
PHP - Interfaces and Traits
Which keyword is used in PHP to specify which trait method to use when two traits have conflicting method names?
Aoverride
Binstead
Cuse
Dinsteadof
Step-by-Step Solution
Solution:
  1. Step 1: Identify the keyword for conflict resolution

    PHP uses the insteadof keyword to resolve conflicts between trait methods with the same name.
  2. Step 2: Confirm correct syntax

    The syntax is: TraitA::methodName insteadof TraitB; to choose TraitA's method over TraitB's.
  3. Final Answer:

    insteadof -> Option D
  4. Quick Check:

    Conflict resolution keyword = insteadof [OK]
Quick Trick: Use 'insteadof' to pick one trait method over another [OK]
Common Mistakes:
  • Using 'instead' instead of 'insteadof'
  • Confusing 'use' keyword for conflict resolution
  • Trying 'override' which is not valid in traits

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes