एक trait भनेको एकाधिक क्लासहरूमा कोड पुन: प्रयोग गर्ने एक संयन्त्र हो जो विरासतद्वारा सम्बन्धित छैनन्। PHP केवल एकल विरासत अनुमति दिएको हुनाले, traits ले विधिहरू (र गुणहरू) क्षैतिजरूपे साझा गर्ने तरिका प्रदान गर्छ — एक "compositional" कोड पुन: प्रयोग को रूप, mixins जस्तै।
Traits ले समाधान गर्ने समस्या
PHP has single inheritance — a class can extend only ONE parent. But you often want
to share the SAME methods across unrelated classes (e.g. logging, timestamps).
Duplicating the code is bad; traits let you reuse it without inheritance.
