Get method's arguments?


Php Problem Overview

I can check all available methods for an object like so:

$methods = get_class_methods($object);

But how can I see which arguments have to be sent to these methods?

Is there a function for this?

Php Solutions

Solution 1 - Php

You can use reflection...

$r = new ReflectionMethod($className, $methodName);
$params = $r->getParameters();
foreach ($params as $param) {
    //$param is an instance of ReflectionParameter
    echo $param->getName();
    echo $param->isOptional();


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRakwardView Question on Stackoverflow
Solution 1 - PhpircmaxellView Answer on Stackoverflow