ID:               35727
 Updated by:       [EMAIL PROTECTED]
 Reported By:      erm at the-erm dot com
-Status:           Open
+Status:           Closed
 Bug Type:         Feature/Change Request
 Operating System: any
 PHP Version:      5.1.1
 New Comment:

Nothing to do here: Use debug_backtrace()


Previous Comments:
------------------------------------------------------------------------

[2005-12-18 23:10:09] erm at the-erm dot com

Description:
------------
Please add a new magic constant like __FUNCTION__ only it 
displays what function the current function was called 
from.  This would be good for debugging, and an error 
handleling function. 

Reproduce code:
---------------
// I know die could do it.  This is just an example
function error($error) {
    echo "There was an error in '".__CALLED_FROM__." '$error";
}


function normal($arg) {
// For debuging:
echo __FUNCTION__.'called from:'.__CALLED_FROM__."\n";
echo $arg;
}

function call_normal() {
   normal("Some Text\n");
}

function call_normal_again() {
   normal("Other Text\n");
}

normal("hi\n";);
call_normal();
call_normal_again();
error("No Error\n");


Expected result:
----------------
normal called from:              
hi             
normal called from:call_normal            
Some Text          
normal called from:call_normal_again         
Other Text       
There was an error in '' No Error   
  
My examples are pretty basic, but I can see where a magic  
constant like __CALLED_FROM__ could be very useful.  
  
You could use it to make sure that the data that a function  
is getting fed is the right data, and if there's an error  
report what function did the call.  So then you can fix it  
faster, and more efficiently. 
 
Thanks ahead of time for adding it, and if not thanks for 
your time. 
  
  

Actual result:
--------------
n/a 
 


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=35727&edit=1

Reply via email to