Google News
logo
PHP - Interview Questions
Explain Traits in PHP?
Traits in PHP are similar to Abstract classes that are not be instantiated on its own. Traits allow us to declare methods that are used by multiple classes in PHP. trait keyword is used to create Traits in PHP and can have concrete and abstract methods.
 
Syntax : 
<?php
  trait TraitName {
  // some code...
}
?>
Advertisement