-1

I searched a lot on internet but I didn't find a proper answer. Sound like traits and inheritance have same work. how traits are different from inheritance and use of traits.

1 Answers1

2

A Trait is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies. The semantics of the combination of Traits and classes is defined in a way which reduces complexity, and avoids the typical problems associated with multiple inheritance and Mixins.

Source: http://php.net/manual/en/language.oop5.traits.php

Mike Stratton
  • 463
  • 1
  • 7
  • 20