PHP 8.6.0 Beta 1 is available for testing

get_declared_traits

(PHP 5 >= 5.4.0, PHP 7, PHP 8)

get_declared_traitsDevuelve un array que contiene todos los traits declarados

Descripción

function get_declared_traits(): array

Parámetros

Esta función no contiene ningún parámetro.

Valores devueltos

Devuelve un array que contiene como valores los nombres de todos los traits declarados.

Véase también

Found A Problem?

Learn How To Improve This PageSubmit a Pull RequestReport a Bug
+add a note

User Contributed Notes 1 note

up
1
@everaldofilho
7 years ago
Example of use:
<?php
namespace Example;
// Declare Trait
trait FooTrait
{
}
// Declare Abstract class
abstract class FooAbstract
{
}
// Declare class
class Bar extends FooAbstract
{
 use FooTrait;
}
// Get all traits declareds
$array = get_declared_traits();
var_dump($array);
/**
 * Result:
 * array(1) {
 * [0] =>
 * string(23) "Example\FooTrait"
 * }
 */
+add a note

AltStyle によって変換されたページ (->オリジナル) /