On Wed, 2008-04-16 at 23:37 -0400, Nathan Nobbe wrote: > all, > > i have heard from various sources that using the & in php can at times be > costly, and therefore, it should not be used when it is not needed. for > example, passing an array by reference because you think youre passing the > actual array is not a good idea. only pass it by reference if a modified > version needs to be handed to the calling code via an actual parameter. > im also wondering about php4 code thats now running under 5; such as > function &returnObject() ... > $a =& new SomeClass() ... > lets suppose, for the sake of arguments, i have my hands on a codebase where > everything actually does count. the code was php4 and is now transitioning > to 5. does anybody know if there would be a performance gain in running the > whole thing through sed to try and strip out the unnecessary & characters ? > any empirical data? If it's faster, it's faster so that would suggest a performance gain... but as many will tell you, and you most likely already know... is the gain worth the effort? BTW, rote replacement of references like that, may not be a good idea. There are times when you really do want a reference to an object... or maybe not... but you or someone else might have done it anyways ;) Contrast: <?php $b = new Foo(); $a = &$b; $a = new Fee(); ?> Versus: <?php $b = new Foo(); $a = $b; $a new Fee(); ?> In the first $b references the instance of Fee since $a is a reference. In the second, $b remains an instance of Foo when $a becomes and instance of Fee. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php