Re: passing by reference via the variable arg list

From: Date: Tue, 24 Sep 2002 15:24:42 +0000
Subject: Re: passing by reference via the variable arg list
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-117430@lists.php.net to get a copy of this message
Not possible, but workaround is to pass the variable name and use it as a variable variable, but for this the variable needs to be global. Trevor Dowling wrote:
Can anyone help with this? I am relativly new to PHP and am trying to use variable numbers of parameters to functions using the func_get_arg(). However, I am unable to determine the correct syntax for passing by reference via the variable arg list. Trevor /* This Works Fine */ function Foo($Index, &$TxtString) { $TxtString = "NewString"; } /* However: how do you pass by reference using a variable number of parameters */ function Foo() { if(func_get_arg(0) == 3) { /* Can you have a variable in function foo that allows access by reference? */ $TxtString = func_get_arg(1); $TxtString = "Second New String"; } } function FooTest() { $StringTest = 'Test'; Foo(2); Foo(3, $StringTest); echo ("$StringText"); }


« previous php.general (#117430) next »