Re: Can you do this
| From: | Christian Reiniger | Date: | Wed, 31 Jan 2001 16:12:29 +0000 |
| Subject: | Re: Can you do this | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-37497@lists.php.net to get a copy of this message | ||
On Wednesday 31 January 2001 16:03, Boget, Chris wrote:
> Now, say I have a function where one of the arguments
> is passed by reference and is modified within the function.
> I can call this function on one line
>
> myFunc( &$modifiedVariable );
>
> and print out the value (if any) of $modifiedVariable on
> the next
>
> echo $modifiedVariable.
>
> So what I am wondering is if you can turn those two
> statements into one? The function is going to get evaluated
> first we already know, but I am not certain how I could
> get the (new) value of $modifiedVariable.
What about using normal pass-by-value and returning the result?
function MyFunc ($SomeVal)
{
$SomeVal += 42;
return $SomeVal;
}
echo MyFunc ($StrangeVal);
Anyway - functions that get their parameters by reference and modify them
can cause much trouble, so better be careful with that.
--
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)
I saw God --------- and she was black.