tags:

views:

1538

answers:

4

Is it possible?

function test()
{
  echo "function name is test";
}
+11  A: 

you want the constant:

__FUNCTION__

http://www.php.net/manual/en/language.constants.predefined.php

Silfverstrom
+7  A: 

You can use the magic constants __METHOD__ or __FUNCTION__ depending on if it's a method or a function... =)

PatrikAkerstrand
__METHOD__ includes the class name, __FUNCTION__ is just that. The latter is equally available in the method of a class.
Alister Bulman
That's true. But it's often useful to get MyClass::methodName instead of methodName.
PatrikAkerstrand
+2  A: 

what i know

you can get all of the function you create

$arr = get_defined_functions();

will print [user] => Array ( [0] => functionname )

Haim Evgi
A: 

If you are using PHP5 you can try this:

function a()
{
  $trace = debug_backtrace();
  echo "Function name is " . $trace[0]["function"];
}
Bing