php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #38549 Cannot reference name of file calling function
Submitted: 2006-08-22 19:32 UTC Modified: 2008-01-01 14:51 UTC
From: phpbugs at replies dot cyways dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.1.5 OS: Linux (CentOS 4.3)
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-08-22 19:32 UTC] phpbugs at replies dot cyways dot com
Description:
------------
It appears to be impossible to determine the name of a file that calls a function stored in another file, e.g., a class library included at startup.  The __FILE__ variable returns the name of the script which contains the function called (the class library in this example), but there doesn't seem to be any comparable variable that returns the name of the file where the function is invoked.  

In my particular case, I have a simple library function debug('debugtext',trigger_level) which compares trigger_level to a global value and prints 'debugtext' as appropriate.  I'd like to be able to print out the name of the file that called this function as well so I can trace errors more efficiently.  As it stands now, I don't see any way to do this other than some kludge that uses get_included_files().




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-07 12:15 UTC] dtyschenko at soft-ukraine dot com
You can use Exceptions call stack
 [2008-01-01 14:51 UTC] magnus@php.net
See http://www.php.net/debug_backtrace
It returns a backtrace as an array with file, line, function and 
arguments used.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 23:01:32 2024 UTC