php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #13944 in a function, I want to know the file/line that CALLED the function
Submitted: 2001-11-05 21:41 UTC Modified: 2003-02-11 12:20 UTC
Votes:10
Avg. Score:4.7 ± 0.6
Reproduced:7 of 7 (100.0%)
Same Version:2 (28.6%)
Same OS:2 (28.6%)
From: tysonlt_SPAM_IS_EVIL at webmedia dot com dot au Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.6 OS: Linux RH7.1
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tysonlt_SPAM_IS_EVIL at webmedia dot com dot au
New email:
PHP Version: OS:

 

 [2001-11-05 21:41 UTC] tysonlt_SPAM_IS_EVIL at webmedia dot com dot au
I would love to be able, from within a function, to find out the file/line no that called me.

For example:

/// some code ///
$x = call_a_function();


function call_a_function() {

    echo "MY LOCATION: __FILE__ : __LINE__";

    /*** This is what I would LOVE ***/
    echo "CALLED FROM: __CALLING_FILE__ : __CALLING_LINE__";
}

That would be fantastic!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-05 10:03 UTC] csaba at ketszeri dot hu
On the Hungarian PHP list this is frequent question, and surely most of the developers -including me :)- would love it too!

Naturally it is another self-administering task to the interpreter, so I would suggest to make it an optional 'developement-time' feature.

Aabout nested includes: it would be good to return a complex data structure, when the programmer can step-back the calling process.

Csabii
 [2002-04-05 10:45 UTC] derick@php.net
80% done with this. Just need some more testing.

regards,
Derick
 [2003-02-11 12:20 UTC] derick@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

Use debug_backtrace() for this in the latest CVS.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 15:01:33 2025 UTC