I am looking to obtain on which line a method was executed in real time for educational purposes.
For example given the following code:
<?php
class FooClass
{
public function testFunction($fakeArgument)
{
//obtener de que archivo y linea de ese archivo fue ejecutado
//output: test.php linea: 12
}
}
$fooClass = new FooClass();
$fooClass->testFunction('Hola Mundo');
Example of the view in the editor:
I have tried with this:
$reflector = new \ReflectionClass('FooClass');
echo $reflector->getFileName();
But this only returns the file where the class is defined; I seek to know the file from which it is invoked ;
How can I get the file and the line where the method is invoked?