Wednesday 16 April 2014

PHP 5.4 traits tutorial,example and concept


As of PHP 5.4.0, PHP implements a method of code reuse called Traits.
PHP 5.4 introduces the concept of traits. Until Traits PHP uses Classical inheritance model in which one class can inherit only one class. In simple words Before PHP 5.4 PHP uses single inheritance model , which makes sometimes difficult to reuse the code.

Traits allow developer to reuse sets of methods freely in several independent classes living in different class hierarchies.