Re: Variable Argument List

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

 



On Fri, Nov 14, 2008 at 8:13 PM, Daniel Kolbo <kolb0057@xxxxxxx> wrote:
> Hello,
>
> I am trying to do something like the following:
>
> <?php
>
> function hello($var1 = 'default1', $var2 = 'default2') {
>   echo "$var1:$var2";
> }
>
> $func= "hello";
> $args = "'yo','bob'";
> $func($args);
>
> ?>
>
> I understand why this outputs:
> 'yo','bob':default2
> However, I want it to output:
> yo:bob
>
> Is this possible? I tried using different combinations of {}, but I cannot
> seem to get it to happen.  I need some kind of "preprocessor" feature
> perhaps.

Its possible. use eval.

eval("$func($args);");

>
> Thanks,
> dK
>



-- 
Blog: http://talk.cmyweb.net/ Follow me: http://twitter.com/shiplu

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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