tags:

views:

125

answers:

4

Hi

I'm using the following as a way of seeing listing the various methods in my developement

print basename(__FILE__) . "::serve_table()"

is there any function that's able to return the name of a class method so I don't have to trpe it each time?

+8  A: 

Use __FUNCTION__ and __LINE__ and __CLASS__ and __METHOD__

grepsedawk
The question was tagged “PHP”, though.
Konrad Rudolph
Yes I realized that and took the gcc reference out, but these constants work in php also.
grepsedawk
+2  A: 

You could use the information provided by debug_backtrace which provides the stack trace in an array.

Konrad Rudolph
+1  A: 

I'm not understanding if you need a way to list all the methods of a class or if you need to retrieve the method name you have just called.

If the former, using reflection:

$class = new ReflectionCLass("classname");
$methods = $class->getMethods();
foreach($methods as $m)
    print $m->getName();
Davide Gualano
+1  A: 

thanks folks - this forum is GREAT