Re: variable-length arguments passed by reference... how?

From: Date: Thu, 29 Apr 2004 22:44:32 +0000
Subject: Re: variable-length arguments passed by reference... how?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-184981@lists.php.net to get a copy of this message
* Thus wrote Tom Rogers (trogers@kwikin.com): > Hi, > > Friday, April 30, 2004, 3:51:19 AM, you wrote: > > > JB> I know I'm probably paranoid, but eval() always bugs me. I think for > JB> what you want to do you can use call_user_func_array() > > JB> $args = func_get_args(); > JB> call_user_func_array('function_to_call', $args); > > JB> > JB> http://www.php.net/manual/en/function.call-user-func-array.php > > The only time eval can be a problem is if you use it on client > supplied data otherwise it is no worse than any other function. It is *very* expensive to use eval, expecially when this has been said: If eval() is the answer, you're almost certainly asking the wrong question. -- Rasmus Lerdorf, BDFL of PHP Here are a couple alternatives: function argbyref(&$args) { $args['arg'] = 'changed'; } $args['arg'] = 'not changed'; argbyref($args); function argwitharray($args) { $args['arg'] = 'changed'; } $arg = 'not changed'; argwitharray(array('arg' => &$arg)); Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#184981) next »