Re: Variables by Reference
| From: | Kevin Hendrix | Date: | Mon, 31 Jul 2000 13:40:27 +0000 |
| Subject: | Re: Variables by Reference | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-9160@lists.php.net to get a copy of this message | ||
Hi.
If your variable is created by reference, then both old and new variable
should point to the same location in memory, so changing one should be visible
when using the other. There is no fancy mirroring going on behind the scenes,
just a couple of variables which point to the same segment of memory.
kevin
--
Kevin Hendrix
Programmer - PennyPI, LLC.
khendrix@pennypi.com
http://www.pennypi.com/
-
kevin Of yuendrikh - International Man of Mystery
Matt wrote:
>
> Hello, i'm just wondering, if a variable is created
> by reference, does that mean that the two variables
> are mirrors of each other ? Or does that mean the
> creating variable can only change the other and
> not the other way round.
>
> Eg.
>
> $init = "hello world";
>
> $init = &$newref;
>
> $newref = "five";
>
> echo $newref; // echos "five";
> echo $init; // was mirrored, echos five too
>
> This is a simple example but i'm sure you all know
> what i'm talking about, so which is it ? Mirrored
> or not ?
>
> Regards, Matt
>