Re: passing by reference via the variable arg list
| From: | Trevor Dowling | Date: | Tue, 24 Sep 2002 15:29:44 +0000 |
| Subject: | Re: passing by reference via the variable arg list | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-117433@lists.php.net to get a copy of this message | ||
Thought as much after some head scratching,
Thanks
"Marek Kilimajer" <kilimajer@webglobe.sk> wrote in message
news:3D9083BA.3050105@webglobe.sk...
> 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");
> >}
> >
> >
> >
> >
> >
>