[nycphp-talk] passing optional arguments by reference
Tim Gales
tgales at tgaconnect.com
Fri Jan 16 12:51:07 EST 2004
Is there some reason this
will not work in your situation:
function tst_func ($statement, &$test1) {
if ( !isset ($test1) ) {
$test1 = "the usual";
}
echo $statement . $test1 . "\n";
}
$tst_str = "something new";
$tst_ref = & $tst_str;
tst_func( "Stuff was: ", $tst_ref );
tst_func( "Stuff was: " );
T. Gales & Associates
'Helping People Connect with Technology'
http://www.tgaconnect.com
p.s. kinda close to what was already posted
sorry for the redundancy and repeating
> -----Original Message-----
> From: talk-bounces at lists.nyphp.org
> [mailto:talk-bounces at lists.nyphp.org] On Behalf Of Daniel Convissor
> Sent: Friday, January 16, 2004 11:34 AM
> To: NYPHP Talk
> Subject: [nycphp-talk] passing optional arguments by reference
>
>
> Hi Folks:
>
> 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?
>
> Thanks,
>
> --Dan
>
> --
> T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
> data intensive web and database programming
> http://www.AnalysisAndSolutions.com/
> 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f:
> 718-854-0409 _______________________________________________
> talk mailing list
> talk at lists.nyphp.org http://lists.nyphp.org/mailman/listinfo/talk
>
More information about the talk
mailing list