Re: & performance issues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Apr 17, 2008, at 5:37 AM, 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?

thx,

-nathan



in PHP5 by default Objects are passed by reference and as you can see at this graph passing array by reference in PHP5 is slower
http://nathan.moxune.com/arrayVsArrayIteratorReport.php



Bojan Tesanovic
http://www.carster.us/





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux