While building application using OOP class, interface play an important role. These two construct are very basic building block of software design. Unlike interface php has new concept called trait.
Trait is nothing new but set of class methods which has implementation details also. But interface have only function declaration not implementation. This makes PHP trait unique from interface.
Let’s take a practial example to understand this awesome feature provided by PHP 5.4 .
See below code which gives small higlight on how to use trait.
You can see that we have used one DriverTrait and used it in multiple class to leaverage same operaitons.
NOTE: This feature is only provided on PHP5.4 and above.