📜  PHP | ReflectionGenerator getExecutingFile()函数

📅  最后修改于: 2022-05-13 01:56:23.560000             🧑  作者: Mango

PHP | ReflectionGenerator getExecutingFile()函数

ReflectionGenerator::getExecutingFile()函数是PHP中的一个内置函数,用于返回指定当前正在执行的生成器的完整路径和文件名。

句法:

string ReflectionGenerator::getExecutingFile( void )

参数:此函数不接受任何参数。

返回值:该函数返回指定当前正在执行的生成器的完整路径和文件名。

下面的程序说明了PHP中的 ReflectionGenerator::getExecutingFile()函数:

方案一:

GFG();
  
// Using ReflectionGenerator over the 
// above generator 'A'
$B = new ReflectionGenerator($A);
  
// Calling the getExecutingFile() function
$C = $B->getExecutingFile();
  
// Getting the full path and file name
// of the currently
// executing generator 'A'
echo $C;
?>

输出:

/home/3ce672c0079010c54e57cdedc34d0188.php

方案二:

Coding_Department();
$B = (new Departments)->HR_Department();
$C = (new Departments)->Marketing_Department();
  
// Using ReflectionGenerator over the 
// above generators
$D = new ReflectionGenerator($A);
$E = new ReflectionGenerator($B);
$F = new ReflectionGenerator($C);
  
// Calling the getExecutingFile() function
// and getting the full path and file 
// name of the currently
// executing generators
echo "File: {$D->getExecutingFile()}";
echo "\n";
echo "File: {$E->getExecutingFile()}";
echo "\n";
echo "File: {$F->getExecutingFile()}";
?>

输出:

File: /home/f12a7584188452b12381b38e3985f9d3.php
File: /home/f12a7584188452b12381b38e3985f9d3.php
File: /home/f12a7584188452b12381b38e3985f9d3.php

参考: https://www. PHP.net/manual/en/reflectiongenerator.getexecutingfile。 PHP