2

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

Working in PHP 5.2.8.

2 Answers 2

2

I think you are looking for get_class_methods():

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.