Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8473 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59440 invoked by uid 1010); 10 Mar 2004 15:30:37 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 59406 invoked from network); 10 Mar 2004 15:30:36 -0000 Received: from unknown (HELO jdi.jdimedia.nl) (212.204.192.51) by pb1.pair.com with SMTP; 10 Mar 2004 15:30:36 -0000 Received: from localhost (localhost [127.0.0.1]) by jdi.jdimedia.nl (8.12.10/8.12.10) with ESMTP id i2AFUTAJ014904; Wed, 10 Mar 2004 16:30:30 +0100 Date: Wed, 10 Mar 2004 16:30:29 +0100 (CET) X-X-Sender: derick@localhost To: Robert Cummings cc: internals@lists.php.net In-Reply-To: <1078932240.5573.132.camel@blobule.suds> Message-ID: References: <1078932240.5573.132.camel@blobule.suds> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] Question about internal workings of references/variables. From: derick@php.net (Derick Rethans) 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. regards, Derick