How to Reuse PHP Code Effectively – Introduction to PHP traits

Originally developed by Rasmus Lerdorf in 1994, PHP is one of the most used general-purpose programming languages. Originally born as a template language, during the years it evolved into a fully-featured language with proper OOP (Object Oriented Programming) support. Its latest incarnation, 7.x, introduced new features like return type declaration for functions and huge performance improvements. PHP is a single inheritance language: this means that a class can inherit only for one parent or base class. To overcome this problem a feature was introduced in the language: traits. In this article we will see how to use it and how it works.