On 10 Mar 2004 Robert Cummings wrote:
> Overhead is minimal since PHP doesn't actually copy the contents of the
> container until an attempt to modify it is made. At which time the
> contents are only actually copied if the internal reference count is
> greater than 0. Generally this means it won't be copied since your
> returning function will no longer be referencing it. This is not to be
> confused with references as programmers work with them in scripts
> themselves.
Rob I have a related question, if you know ... what is the point at
which passing objects by reference instead of by value provides a
performance benefit?
It sounds from the above like if you are not modifying the object in
the called code then passing by value is always best because this is
treated as a pass by reference unless and until there is a
modification, so there is no performance cost. (I udnerstand that if
modifying it then it must be passed by reference.)
If that's right, then ...
- does the same apply to arrays?
- what happens if you pass an object by value and then call one of
its methods which does not modify any data? Does the object get
copied?
Thanks for any insights ...
--
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php