English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Class/Object function reference manual
The get_declared_traits() function returns an array of all defined traits
get_declared_traits( void );
Returns an array containing the names of all defined traits.
Serial number | Parameters and description |
---|---|
1 | void void indicates that no parameters are required. |
Returns an array containing the names of all defined traits. Returns NULL on failure.
The following is the usage of this function-
<?php namespace Example; // Declare Trait trait FooTrait { } //Declare abstract class abstract class FooAbstract { } //Declare class class Bar extends FooAbstract { use FooTrait; } //Get all property declarations $array = get_declared_traits(); var_dump($array); ?>Test and see ‹/›
Output result:
array(1) { [0] => string(23) "Example\FooTrait" }