PHP | ReflectionGenerator getExecutingLine() Function
Last Updated :
20 Dec, 2019
The ReflectionGenerator::getExecutingLine() function is an inbuilt function in PHP which is used to return the line number of the specified currently executing statement in the generator.
Syntax:
int ReflectionGenerator::getExecutingLine( void )
Parameters: This function does not accept any parameters.
Return Value: This function returns the line number of the specified currently executing statement in the generator.
Below programs illustrate the ReflectionGenerator::getExecutingLine() function in PHP:
Program 1:
<?php
class Company {
public function GFG() {
yield 0;
}
}
$A = ( new Company)->GFG();
$B = new ReflectionGenerator( $A );
$C = $B ->getExecutingLine();
echo $C ;
?>
|
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 $D ->getExecutingLine();
echo "\n" ;
echo $E ->getExecutingLine();
echo "\n" ;
echo $F ->getExecutingLine();
?>
|
Reference: https://www.php.net/manual/en/reflectiongenerator.getexecutingline.php
Share your thoughts in the comments
Please Login to comment...