Posted by gosha bine on 08/01/07 09:04
On 01.08.2007 10:11 FFMG wrote:
> What is the difference between
>
> // --
> $params = array( $stuff);
> $myFn = 'foo';
> $myFn($params)
> // --
>
> And
>
> // --
> $params = array( $stuff);
> $myFn = 'foo';
> call_user_func_array( $myFn, $params );
> // --
>
> Wont they both achieve the same result?
>
call_user_func_array is useful when the number of parameters to a called
function is variable or unknown, for example:
function nice_dump() {
$params = func_get_args();
echo "<pre>";
call_user_func_array('var_dump', $params);
echo "</pre>";
}
nice_dump(1, 2, 3);
--
gosha bine
makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
[Back to original message]
|