You are writing a PHP script and you need to define a trait. How would you do this?

  • Using the trait keyword followed by the trait name and its definition
  • Using the class keyword followed by the trait name and its definition
  • Using the trait keyword followed by the trait name and its implementation details
  • Using the interface keyword followed by the trait name and its implementation details
To define a trait in PHP, you would use the trait keyword followed by the trait name and its definition. Traits allow you to define reusable blocks of code that can be included in multiple classes.
Add your answer
Loading...

Leave a comment

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