php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #27639 Function Level Constands
Submitted: 2004-03-18 15:41 UTC Modified: 2004-03-18 16:08 UTC
From: hallow at webmages dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.3.4 OS: Linux
Private report: No CVE-ID: None
 [2004-03-18 15:41 UTC] hallow at webmages dot com
Description:
------------
In building my own functions, in particular an include work-a-like that does some pre and post processing, it would be very handy to have a __CALLER__ constant that indicates the file the function was called from, and and a __CLINE__ constant or something similar that indicates the line number in the caller where the function was called from.

It appears that the only way to accomplish this within PHP by having the function take __FILE__ and __LINE__ as parameters, which for an potentially oft used function makes for a lot of extra typing.



Reproduce code:
---------------
function my_include(file,caller,line) {
   echo "Called from: ",$caller,", line number: ", $line;
   include(file);
}

my_include(file,__FILE__,__LINE__);  

could be:

function my_include(file) {
   echo "Called from: ", __CALLER__ , " , line number: ", __CLINE__;
   include(file);
}

my_include(file);


Expected result:
----------------
Called from: SOMEFILE, line number: SOMEINT


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-18 16:08 UTC] rasmus@php.net
You can get this info via debug_backtrace()
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Dec 01 04:00:01 2025 UTC