php8.5
Home/ Manual/ reflection / reflectiongenerator/ ReflectionGenerator::getExecutingFile

ReflectionGenerator::getExecutingFile

PHP function Edit on GitHub ✎

(PHP 7, PHP 8)

Gets the file name of the currently executing generator

Description

ReflectionGenerator::getExecutingFile(): string

Get the full path and file name of the currently executing generator.

Parameters Parameters

Return Values

Returns the full path and file name of the currently executing generator.

Examples

ReflectionGenerator::getExecutingFile example

php
<?php

class GenExample
{
    public function gen()
    {
        yield 1;
    }
}

$gen = (new GenExample)->gen();

$reflectionGen = new ReflectionGenerator($gen);

echo "File: {$reflectionGen->getExecutingFile()}";

The above example will output something similar to:

output
File: /path/to/file/example.php

See Also

  • ReflectionGenerator::getExecutingLine
  • ReflectionGenerator::getExecutingGenerator

Source: reference/reflection/reflectiongenerator/getexecutingfile.xml · from the official PHP manual (php/doc-en)