Checks if the trait exists
Syntax
trait_exists ( string $traitname [, bool $autoload ] ) : bool
Parameters
traitname
Name of the trait to check
autoload
Whether to autoload if not already loaded.
Return
Returns TRUE if trait exists, FALSE if not, NULL in case of an error.
Examples
1 · traitname
<? trait mytrait { } $traitname = "mytrait"; $return = trait_exists($traitname); var_export($return); ?>
true
2 · autoload · false
<? trait mytrait { } $traitname = "mytrait"; $autoload = false; $return = trait_exists($traitname, $autoload); var_export($return); ?>
true
3 · autoload · true
<? trait mytrait { } $traitname = "mytrait"; $autoload = true; $return = trait_exists($traitname, $autoload); var_export($return); ?>
true