Trait એ એક પદ્ધતિ છે જે અનેક વર્ગોમાં કોડ ફરીથી વાપરવા માટે છે જે વારસા દ્વારા સંબંધિત નથી. કારણ કે PHP માત્ર એક વારસો માટવતર હોય છે, traits નો ઉપયોગ પદ્ધતિઓ (અને ગુણધર્મો) આડીથી શેર કરવા માટે એક રસ્તો આપે છે — "કમ્પોઝીશનલ" કોડ પુનઃવાપર જેવા, 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.
