Find the best answer to your question, help others answer theirs

If you are going to use a passage of Lorem Ipsum, you need to be sure there
isn't anything embarrassing hidden in the middle of text.

  • Anybody can ask a question
  • Anybody can answer
  • The best answers are voted up and rise to the top
What is Traits in PHP?
Asked 8 वर्ष पहले
Viewed 730 times

1 Answer

2
  • Traits are a mechanism for code reuse in single inheritance.
  • A Trait is similar to a class, but only intended to group functionality in a fine-grained and consistent way.
  • It is not possible to instantiate a Trait but addition to traditional inheritance. It is intended to reduce some limitations of single inheritance to reuse sets of methods freely in several independent classes living in different class hierarchies.
  • Multiple Traits can be inserted into a class by listing them in the use statement, separated by commas(,).
  • If two Traits insert a method with the same name, a fatal error is produced.
Edit
avatar
Majed Badawi
15.5k 3 10 26
answered 8 hours ago

Leave a Comment

[named hyperlinks] (https://example.com)
**bold**
_italic_

Your Answer

Drop files here or click to upload.