PHP | ReflectionClass isAnonymous() Function

The ReflectionClass::isAnonymous() function is an inbuilt function in PHP which is used to check the specified class is anonymous or not.
Syntax:
bool ReflectionClass::isAnonymous( void )
Parameters: This function does not accept any parameters.
Return Value: This function returns True on success or False otherwise.
Below programs illustrate the ReflectionClass::isAnonymous() function in PHP:
Program 1:
| <?php // Initialising an anonymous class$anonymousClass= newclass{}; // Using ReflectionClass over the anonymous class$A= newReflectionClass($anonymousClass); // Calling the isAnonymous() function $B= $A->isAnonymous(); // Getting the value true or falsevar_dump($B);?> | 
Output:
bool(true)
Program 2:
| <?php // Defining a user-defined class CompanyclassCompany {    privatefunctionzambiatek() {}    privatefunctionGFG() {}} // Using ReflectionClass over the // Company class$A= newReflectionClass('Company'); // Calling the isAnonymous() function $B= $A->isAnonymous(); // Getting the value true or falsevar_dump($B);?> | 
Output:
bool(false)
Reference: https://www.php.net/manual/en/reflectionclass.isanonymous.php
 
				 
					


