Getting the name of the current function in php

Is there a function that can return the name of the current function executed by the program?

+44
function php
Jan 22 '10 at 8:21
source share
2 answers

Yes, you can get the function name with magic constant __FUNCTION__

 class foo { function print_func() { echo __FUNCTION__; } function print_method() { echo __METHOD__; } } $obj = new foo(); $obj->print_func(); // Returns: print_func $obj->print_method(); // Returns: foo::print_method 
+114
Jan 22 '10 at 8:22
source share
+10
Jan 22 '10 at 8:23
source share



All Articles