PHP ReflectionClass isTrait() Function
The ReflectionClass isTrait() function is an inbuilt function in PHP that is used to check if any trait is available or not.
Syntax:
bool ReflectionClass isTrait()
Parameters: This function does not accept any parameter.
Return Value: This function returns TRUE if the trait is available, otherwise FALSE.
Below programs illustrate the ReflectionClass isTrait() function in PHP:
Program 1:
php
<?php
trait Company {
public function GeeksforGeeks() {
}
}
$obj = new ReflectionClass( 'Company' );
$A = $obj ->isTrait();
var_dump( $A );
?>
|
Output:
bool(true)
Program 2:
php
<?php
class Department{
}
$obj = new ReflectionClass( 'Department' );
$Result = $obj ->isTrait();
var_dump( $Result );
?>
|
Output:
bool(false)
Reference: https://www.php.net/manual/en/reflectionclass.istrait.php
Last Updated :
22 Feb, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...