Answer the question
In order to leave comments, you need to log in
Where might a trait be needed in PHP?
[I already read this question on toaster, but it didn't help me. So there is no need to delete and complain about the question for the existence of such a question. Thank you for your understanding.]
Hello!
I read about traits, but did not understand where it could be useful in practice. Okay, they save the amount of code, but where in practice it can come in handy. Make inheritance and all. That's economy and beauty. In what case would inheritance be preferable to traits?
Why can't the trait Cat be made a subclass of Animal and Tiger a subclass of Cat in this code? Everything is quite logical.
Thanks in advance to everyone who helps!
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question