B Seven
B Seven

Reputation: 45943

How to get an array of all functions within a class in PHP?

How to get an array of all functions within a class in PHP?

Working in PHP 5.2.8.

Upvotes: 2

Views: 95

Answers (2)

Ynhockey
Ynhockey

Reputation: 3932

I think you are looking for get_class_methods():

http://il2.php.net/manual/en/function.get-class-methods.php

Upvotes: 2

user142162
user142162

Reputation:

You can do this using ReflectionClass

$class = new ReflectionClass('ClassName');
$methods = $class->getMethods();

$methods will return an array of ReflectionMethod objects, which you can then iterate through and get detailed information about each method:

foreach($methods as $method)
{
    // $method->getName()
    // $method->getParameters()
    // etc.
}

Upvotes: 1

Related Questions