What are TRAITS in PHP ?

What are Trait in PHP ? Why do we need Trait in PHP ?

In this article we will be working on a very new feature which is introduced in PHP 5.4 which is Traits in PHP.
Traits are mechanisms which help and increase in code re-usability, and also serves perfectly to solve the problem of multiple inheritance in php.

For example we have two or more than two classes that need to access a method / function .
So to solve this before version 5.4 you were suppose to do something like :

Continue reading