How to get the name of current function in PHP

2 Answers

0 votes
function currentFunctionName() {
    echo __FUNCTION__;
}
 
currentFunctionName();
 
 
 
 
 
/*
run: 
 
currentFunctionName 
 
*/

 



answered Jul 2, 2016 by avibootz
edited Dec 2, 2023 by avibootz
0 votes
function currentFunctionName() {
    $bt = debug_backtrace();
    
    return $bt[0]['function'];
}

echo currentFunctionName();




/*
run:

currentFunctionName

*/

 



answered Dec 2, 2023 by avibootz

Related questions

1 answer 165 views
1 answer 98 views
2 answers 188 views
1 answer 193 views
193 views asked Feb 22, 2019 by avibootz
1 answer 183 views
1 answer 201 views
...