PHP ReflectionClass getFileName () Function

PHP

Syntax:
string ReflectionClass::getFileName (void)
Parameters:This function takes no parameters.Return Value:This function returns the name of the file in which the class was defined, or returns false if the file is not found.The following programs illustrate the ReflectionClass::getFileName() function in PHP:Program 1:  
// Definition custom class
// named as Departments class Departments { static $Dept1 = ' CSE' ; private static $Dept2 = 'ECE' ; public static $Dept3 = 'EE' ; }  
// Using ReflectionClass over the Departments class $ReflectionClass = new ReflectionClass ( 'Departments' );  
// Calling getFileName() functions $A = $ReflectionClass -> getFileName();  
// Get the file name
// where the class was defined var_dump ( $A ); ?>
Exit:
string (23 ) "C: xampphtdocsgfg.php"
Program 2:  
// Using ReflectionClass $ReflectionClass = new ReflectionClass ( 'ReflectionClass' );  
// Calling getFileName() functions $A = $ReflectionClass -> getFileName();  
// Get the file name
// where the class was defined var_dump ( $A ); ?>
Exit:
bool (false )
Link: https://www.php.net /manual/en/reflectionclass.getfilename.php



Get Solution for free from DataCamp guru