Re: Re: Confusing pointers in PHP 4 and 5

From: Date: Wed, 09 Jun 2004 14:00:35 +0000
Subject: Re: Re: Confusing pointers in PHP 4 and 5
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-10346@lists.php.net to get a copy of this message
In general, if you don't mean for it to be a reference semantically, you are best off not using references at all. PHP will do the right thing. Andi At 10:32 AM 6/9/2004 +0200, Bert Slagter wrote:
Derick Rethans wrote:
On Wed, 9 Jun 2004, Stephan Schmidt wrote:
Yes, that is correct.
No, it is not. 'copying' a variable copies the structure to contain the variable, but not the data, but does NOT make a reference as that's a different concept. You are right that the data associated with a variable container is only copied when it is modified. Derick
Hm! I should 've known this - someone told this on a PHP Conference :). I created a testcase where references to a string are a lot faster then normal copies by modifying the data after the assignment. But when I leave the data unaltered, I don't see a significant difference between a copy and a reference. So I assume that the cost of referencing is about equal to the cost of copying the structure..? But as a rule of thumb: references to primary types (i.e. strings, arrays) are only faster when the data is modified, am I right? Bert -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#10346) next »