You have a PHP script and you need to create a class that uses a trait. How would you do this?

  • Using the use keyword followed by the trait name
  • Using the include keyword followed by the trait name
  • Using the extend keyword followed by the trait name
  • Using the require keyword followed by the trait name
To create a class that uses a trait in PHP, you would use the use keyword followed by the trait name. This allows you to include the functionality defined in the trait within the class. The use keyword is used to import the trait into the class and make its methods and properties available for use.
Add your answer
Loading...

Leave a comment

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