PHP | ReflectionGenerator getTrace() Function Last Updated : 26 Dec, 2022 Comments Improve Suggest changes Like Article Like Report The ReflectionGenerator::getTrace() function is an inbuilt function in PHP which is used to return the trace of the specified currently executing generator. Syntax: array ReflectionGenerator::getTrace ( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the trace of the specified currently executing generator. Below programs illustrate the ReflectionGenerator::getTrace() function in PHP: Program_1: php <?php // Initializing a user-defined class Company class Company { public function GFG() { yield 0; } } // Creating a generator 'A' on the above // class Company $A = (new Company)->GFG(); // Using ReflectionGenerator over the // above generator 'A' $B = new ReflectionGenerator($A); // Calling the getTrace() function $C = $B->getTrace(); // Getting the trace of the specified // executing generator 'A' var_dump($C); ?> Output:array(0) { } Program_2: php <?php // Initializing a user-defined function function Department1() { yield 1; } function Department2() { yield from Department1(); } function Department3() { yield from Department2(); } // Creating a generator $A = Department3(); // Starting the generator $A->valid(); // Using ReflectionGenerator() over the // above generator 'A' $A = new ReflectionGenerator($A); // Calling the getTrace() function $B = $A->getTrace(); // Getting the trace of the // executing generator 'A' var_dump($B); ?> Output:array(2) { [0]=> array(4) { ["file"]=> string(42) "/home/5ae62f6794b195f5dfeff893639bead9.php" ["line"]=> int(10) ["function"]=> string(11) "Department1" ["args"]=> array(0) { } } [1]=> array(4) { ["file"]=> string(42) "/home/5ae62f6794b195f5dfeff893639bead9.php" ["line"]=> int(15) ["function"]=> string(11) "Department2" ["args"]=> array(0) { } } } Reference: https://www.php.net/manual/en/reflectiongenerator.gettrace.php Create Quiz Comment K Kanchan_Ray Follow 0 Improve K Kanchan_Ray Follow 0 Improve Article Tags : Web Technologies PHP PHP-function PHP- Reflection Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like