What is Traits in PHP

Prem Tiwari - - PHP Tutorials

In this tutorial, I will explain what is Traits in PHP and how to use Traits in your PHP script.

Traits are a mechanism that allows you to create reusable code in PHP where multiple inheritances are not supported. To create a Traits we use keyword trait in the PHP script.

Example of Traits

Below example explain how to use Traits in your PHP script.

Liked this tutorial? Do Like & share with your friends 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.