Is there a function that can return the name of the current function a program is executing?
+7
A:
Yes you can with
__FUNCTION__
class trick
{
function doit()
{
echo __FUNCTION__;
}
function doitagain()
{
echo __METHOD__;
}
}
$obj=new trick();
$obj->doit();
output will be ---- doit
$obj->doitagain();
output will be ----- trick::doitagain
Sarfraz
2010-01-22 08:22:57
Awesome. Magic constants! I wasn't sure if there were variables for this but there are. This will save me a lot of code, thank you.
Cian E
2010-01-22 08:47:08
@cianestro: you welcome, thank you :)
Sarfraz
2010-01-22 09:55:38
A:
Maybe via debug_backtrace http://www.php.net/manual/en/function.debug-backtrace.php
robertbasic
2010-01-22 08:23:50