trait_exists
Description
The trait_exists of Class / Object for PHP checks if the trait exists.
Syntax
trait_exists( string $trait, bool $autoload = true ): bool
Parameters
trait
Name of the trait to check.
autoload
Whether to autoload if not already loaded.
Return
Returns true if trait exists, and false otherwise.
Examples
1 · trait
<? trait mytrait { } $trait = "mytrait"; $return = trait_exists($trait); var_export($return); ?>
true
2 · autoload · false
<? trait mytrait { } $trait = "mytrait"; $autoload = false; $return = trait_exists($trait, $autoload); var_export($return); ?>
true
3 · autoload · true
<? trait mytrait { } $trait = "mytrait"; $autoload = true; $return = trait_exists($trait, $autoload); var_export($return); ?>
true