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



Reply via email to