Re: Question about internal workings of references/variables.
| From: | Robert Cummings | Date: | Wed, 10 Mar 2004 17:08:00 +0000 |
| Subject: | Re: Question about internal workings of references/variables. | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-8474@lists.php.net to get a copy of this message | ||
On Wed, 2004-03-10 at 10:30, Derick Rethans wrote:
> On Wed, 10 Mar 2004, Robert Cummings wrote:
>
> > Hi Internals,
> >
> > I'd like to confirm/refute some knowledge I think I have of the PHP
> > internal workings with respect to variables and references. I believe
> > that when a variable is assigned the value of another variable an
> > internal reference is created and some bit is used to keep track of
> > whether the value should be copied when an attempt is made to change
> > either the original variable or the newly assigned variable (maybe this
> > isn't the case for integers or floats since the performance would be
> > similar). Can anyone confirm or elaborate further?
>
> yes, that is true and called "copy-on-write". It's done for all types of
> variables though.
>
> > Also I think I remember hearing once upon a time that creating a
> > reference in PHP script is more work than creating a copy when the copy
> > won't be altered? Can this be confirmed also?
>
> Never tried that myself, but I believe it to be true.
> >
> > Last but not least, do objects work under the same principles?
>
> yes, in php 4 they do. in php 5 it is true for "object-handles" and not
> objects, but that shouldn't be of any concern.
Thanks Derick, now I'll be sure to not misinform others :)
Cheers,
Rob
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'