PHP | ReflectionGenerator getExecutingFile() Function
Last Updated :
19 Dec, 2019
The ReflectionGenerator::getExecutingFile() function is an inbuilt function in PHP which is used to return the full path and file name of the specified currently executing generator.
Syntax:
string ReflectionGenerator::getExecutingFile( void )
Parameters: This function does not accept any parameters.
Return Value: This function returns the full path and file name of the specified currently executing generator.
Below programs illustrate the ReflectionGenerator::getExecutingFile() function in PHP:
Program 1:
<?php
class Company {
public function GFG() {
yield 0;
}
}
$A = ( new Company)->GFG();
$B = new ReflectionGenerator( $A );
$C = $B ->getExecutingFile();
echo $C ;
?>
|
Output:
/home/3ce672c0079010c54e57cdedc34d0188.php
Program 2:
<?php
class Departments {
public function Coding_Department() {
yield 0;
}
public function HR_Department() {
yield 1;
}
public function Marketing_Department() {
yield 2;
}
}
$A = ( new Departments)->Coding_Department();
$B = ( new Departments)->HR_Department();
$C = ( new Departments)->Marketing_Department();
$D = new ReflectionGenerator( $A );
$E = new ReflectionGenerator( $B );
$F = new ReflectionGenerator( $C );
echo "File: {$D->getExecutingFile()}" ;
echo "\n" ;
echo "File: {$E->getExecutingFile()}" ;
echo "\n" ;
echo "File: {$F->getExecutingFile()}" ;
?>
|
Output:
File: /home/f12a7584188452b12381b38e3985f9d3.php
File: /home/f12a7584188452b12381b38e3985f9d3.php
File: /home/f12a7584188452b12381b38e3985f9d3.php
Reference: https://www.php.net/manual/en/reflectiongenerator.getexecutingfile.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...