[nycphp-talk] passing optional arguments by reference
Dan Cech
dcech at phpwerx.net
Sat Jan 17 10:04:05 EST 2004
> I'm want the parameters for a function to be passed by reference.
> Normally, that's accomplished by placing a & in front of the variable.
> Trick is, the argument in question needs to be optional. Placing a & in
> front of an optional parameter creates a parse error.
>
> CODE:
> function &execute($stmt, &$data = array()) {
> }
>
> ERROR:
> Parse error: parse error, unexpected '=', expecting ')'
>
> Removing the "= array()" makes it parse fine.
>
> So, is there a way to do this, please?
Looking here: <http://www.php.net/zend-engine-2.php>
It appears this syntax is supported in PHP5.
Dan
More information about the talk
mailing list