call_user_func_array vs ReflectionMethod
<p>I was wondering about what the best practices are when it comes to call a class method using the above functions to fill up a method call dynamically using an array!</p>

<p>What advantages and disadvantages do I have? I mean, it seems the RefelectionMethod + invokeArgs option is up to 40% faster than the call_user_funcion in certain conditions… but do I miss something?</p>

<p>thanks.</p>

<p>As requested i will add a little benchmark of my scenario where i needed refereces to be passed... i know its a very specific case and that this is not stricly related to the question above!</p>

<pre><code>class foo { public function bar(&amp;$a, &amp;$b, &amp;$c) { /* */ } }
$t1 = microtime(true);
$arr = array(1,2,3);
$foo = new foo;
$rfl = new ReflectionMethod('foo', 'bar');
for ($i=0; $i &lt; 10000; ++$i)
{   
    $rfl-&gt;invokeArgs($foo, $arr);   
}

$t2 = microtime(true);
echo sprintf("\nElapsed reflectionmethod  : %f", $t2 - $t1);
$t1 = microtime(true);
$arr = array(1,2,3);
$foo = new foo;

for ($i=0; $i &lt; 10000; ++$i)
{
    foreach( $arr as $k =&gt; $v ) $ref[$k] = &amp;$arr[$k];       
    call_user_func_array( array($foo, 'bar'), $arr);
}

$t2 = microtime(true);
echo sprintf("\nElapsed calluserfuncarray : %f", $t2 - $t1);
</code></pre>

<p>the result</p>

<pre><code>Elapsed reflectionmethod  : 0.025099
Elapsed calluserfuncarray : 0.051189
</code></pre>

<p><strong>I really would just like to know when its better to use one versus the other, and why! its not strictly related to speed though!</strong></p>
