2

How is it possible to output methods in classes?

class Test {
    function wee($param1, $param2){
        return $param1.$param2;
    }
}

I want to output the method wee and all its content.. I also need to know the names and how many parameters the method requires

1 Answer 1

6

Use ReflectionClass

$class = new ReflectionClass('Test');
$methods = $class->getMethods();
$parameters = $class->getMethod('wee')->getParameters();
var_dump($methods);
var_dump($parameters);

or a more stylized output

echo "<pre>";
$class = new ReflectionClass('Test');
$methods = $class->getMethods();
foreach($methods as $name){
    echo $name;
}
echo "</pre>";
Sign up to request clarification or add additional context in comments.

1 Comment

Hey @Mihai, you made a typo in the anchor text of your link.

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.