Re: Passing arguments as they are received to another function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You might want to take a look at
http://php.net/manual/en/function.call-user-func-array.php



On Sat, Jul 12, 2008 at 4:57 PM, Luigi Perroti <luigi.perroti@xxxxxxxxxxxxxx>
wrote:

> Hello, I'm trying to implement a few simple wrappers for some PHP
> functions.
>
> Here's an example of what I'm trying to do:
>
> function myWrapper() {
>    return defaultPhpFunction(func_get_args());
> }
>
> The example above is broken since I'm just passing an array to the original
> function.
>
> The only way to achieve the desired result that I've found is something
> like
> this:
>
> function myWrapper() {
>    $argsNumber = func_num_args();
>    if ($argsNumber == 1) {
>        return defaultPhpFunction(func_get_arg(0));
>    }
>    elseif ($argsNumber == 2) {
>        return defaultPhpFunction(func_get_arg(0), func_get_arg(1));
>    }
>    // ...
>    // ...
>    // ...
> }
>
> Since the above code is clumsy to say the least any advice would be
> welcome.
> Thanks for your time!
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux