Re: Re: Confusing pointers in PHP 4 and 5
| From: | Bert Slagter | Date: | Wed, 09 Jun 2004 08:32:09 +0000 |
| Subject: | Re: Re: Confusing pointers in PHP 4 and 5 | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-10336@lists.php.net to get a copy of this message | ||
Derick Rethans wrote:
On Wed, 9 Jun 2004, Stephan Schmidt wrote: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? BertYes, 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