Re: Which file called the function?
| From: | Nilesh Ashra | Date: | Thu, 20 Dec 2007 14:42:34 +0000 |
| Subject: | Re: Which file called the function? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-266152@lists.php.net to get a copy of this message | ||
On 20 Dec 2007, at 14:37, Christoph Boget wrote:
Let's say I have the following 3 files global.php <? function myFunc() { echo __FILE__; } ?> one.php <? include( 'global.php' ); echo 'You are in file: '; myFunc(); ?> two.php <? include( 'global.php' ); echo 'You are in file: '; myFunc(); ?> In each case, what is echoed out for __FILE__ is global.php. Apart from analyzing the debug_backtrace array, is there any way that myFunc() would display "one.php" and "two.php" respectively? thnx, ChristophHi Christoph, 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? Regards, Nilesh