plz help: is there a way to get the name of a class like:
class A { function A { echo $this->get_name(); } function B { echo $this->get_function_name(); } }
i need it to log some actions and i don't wanna set variables to get this possibility...
thx
$methods = get_class_methods(get_class($myClass));
http://www.php.net/manual/en/function.get-class.php
i can use that to get the name of the class, but how about the method / function i'm in?
so i wanna log the actions like function B { // do something writeLog("somethings done", $this->get_this_function_name()) }
very good question,
have you tried the keywork/reserved word
FUNCTION
That might work
hmm, no, that doesn't work... 🙁
That's because FUNCTION is not a php constant.
Since you're in the class/function of interest, why not just hard code them?
class A { function A { echo "A::A"; } function B { echo "A::B"; } }
sure i could do that, but thats not what i want i'm searching for a dynamic way to get the functions name
i hate hardcoding so if i would have to rename a function i always have to look for any variables that i have to change...