Re: HELP: Detecting the name of the file a function is being called from
| From: | André Cerqueira | Date: | Tue, 10 Feb 2004 06:38:11 +0000 |
| Subject: | Re: HELP: Detecting the name of the file a function is being called from | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177251@lists.php.net to get a copy of this message | ||
function called_from_file(){
$backtrace = debug_backtrace();
print $backtrace[0]['file'];
}
check: http://www.php.net/manual/en/function.debug-backtrace.php
Samuel Ventura wrote:
Hi there I have 2 scripts: //////////////////////////////// <?php /* test1.php */ function called_from_file(){ print __FILE__ } ?> /////////////////////////////// <?php /* test2.php */ include("test1.php"); called_from_file(); ?> ///////////////////////////////// I get the output test1.php what I need is to detect the name of the script from which I called the function, (test2.php) in this case. For this application, it is not practical to pass an aditional parameter to the function specifying the caller, i need independence. Any ideas? __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html