Reputation: 4303
Is it possible (in an efficient manor) to retrieve the filename (and line if possible) of the previous command that called a function in another (included) file?
For example:
Foo.php
function foo() {
bar();
}
Bar.php
function bar() {
// some stuff that will show when the above is executed:
// Foo.php, line 2 (last bit if possible)
}
Upvotes: 2
Views: 54
Reputation: 158250
Thats a job for debug_backtrace()
:
function test($param)
{
echo "$param";
var_dump(debug_backtrace());
}
Upvotes: 5