Difference between revisions of "PHP/trait"
< PHP
		
		
		
		Jump to navigation
		Jump to search
		| Line 3: | Line 3: | ||
| The autoloader treats traits like classes. | The autoloader treats traits like classes. | ||
| + | |||
| + | Traits are used via one sense of the '''{{l/sub|use}}''' keyword. | ||
| ==Functions== | ==Functions== | ||
| * [https://www.php.net/manual/en/function.trait-exists.php trait_exists()]: returns TRUE if the trait has been declared in code that has executed.   | * [https://www.php.net/manual/en/function.trait-exists.php trait_exists()]: returns TRUE if the trait has been declared in code that has executed.   | ||
Latest revision as of 22:25, 13 April 2022
About
In PHP, a trait is a set of member-variables and method-functions which can be added to the declaration of any class.
The autoloader treats traits like classes.
Traits are used via one sense of the use keyword.
Functions
- trait_exists(): returns TRUE if the trait has been declared in code that has executed.
There does not appear to be a function to detect if a given class or object uses a given trait.
Links
- Official: traits