PHP | ReflectionClass getFileName() Function
Last Updated :
26 Nov, 2019
The ReflectionClass::getFileName() function is an inbuilt function in PHP which is used to return the filename of the file in which the class has been defined or returns false if the file is not found.
Syntax:
string ReflectionClass::getFileName( void )
Parameters: This function does not accept any parameters.
Return Value: This function returns the filename of the file in which the class has been defined or returns false if the file is not found.
Below programs illustrate the ReflectionClass::getFileName() function in PHP:
Program 1:
<?php
class Departments {
static $Dept1 = 'CSE' ;
private static $Dept2 = 'ECE' ;
public static $Dept3 = 'EE' ;
}
$ReflectionClass = new ReflectionClass( 'Departments' );
$A = $ReflectionClass ->getFileName();
var_dump( $A );
?>
|
Output:
string(23) "C:\xampp\htdocs\gfg.php"
Program 2:
<?php
$ReflectionClass = new ReflectionClass( 'ReflectionClass' );
$A = $ReflectionClass ->getFileName();
var_dump( $A );
?>
|
Reference: https://www.php.net/manual/en/reflectionclass.getfilename.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...