Re: Which file called the function?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Christoph Boget wrote:
I believe __FILE__ is resolved at compile time, not run-time which means what you're seeing is expected behavior. I'm not sure how you'd get the name of the file that a function call was made from. Could you explain why you need this information in your application, and perhaps someone might offer an alternative solution?

I'm not saying it's not expected behavior.  In fact, that exactly what I
would expect based on what the docs say.  I'm just asking if there is
another way to get the script file name that's calling the function.

I need it primarily for debugging purposes.  I've got a single function
that's called by several files.  And instead of modifying all the files
calling the function to add logging, it would be nice to just modify the
function, adding logging only to it to also include what script called it.
I know I can get the information from debug_backtrace but I figured there
might be a better/easier way.

There isn't. The backtrace is the only thing that can get the call stack.

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux