From:             erm at the-erm dot com
Operating system: any
PHP version:      5.1.1
PHP Bug Type:     Feature/Change Request
Bug description:  magic constant __CALLED_FROM__

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 bug report at http://bugs.php.net/?id=35727&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=35727&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=35727&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=35727&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=35727&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=35727&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=35727&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=35727&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=35727&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=35727&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=35727&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=35727&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=35727&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=35727&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=35727&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=35727&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=35727&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=35727&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=35727&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=35727&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=35727&r=mysqlcfg

Reply via email to