Lars B. Jensen wrote:
Is there any way, I from one function can identify which other function called it, without parameter passing the name manually ?
I still question whether its correct to design a function which requires this. I thought the idea of encapsulating code inside a function is that its non-dependent/black-boxed.... still for every rule there is an exception!
Please don't post twice in an hour if you haven't yet received your answer. With that in mind, I have an answer for you. :-)
maybe Lars thought his post had disappeared into /dev/null, not altogether strange considering the fluctuating time delays in posts being sent out! then maybe he's an impatient s.o.b ;-)
Use debug_backtrace(): http://www.php.net/debug-backtrace
Harry Fuecks has an excellent post on how to use debug_backtrace() here: http://www.sitepoint.com/blog-post-view.php?id=157007
He has a lot of those (excellent posts that is), but he is really giving an example of debugging not writing code that relies on a debug_ function.
I don't think debug_backtrace() should be used like this, having said that it will work - but I can only imagine that its a heavy function to call (because it has to 'analyse' the stack in order to return alot of info, nearly all of which is not needed in the case Lars presented)
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php