使用範例
<?php
namespace Example;
// 宣告 Trait
trait FooTrait
{
}
// 宣告抽象類別
abstract class FooAbstract
{
}
// 宣告類別
class Bar extends FooAbstract
{
use FooTrait;
}
// 取得所有已宣告的 Traits
$array = get_declared_traits();
var_dump($array);
/**
* 結果:
* array(1) {
* [0] =>
* string(23) "Example\FooTrait"
* }
*/