Friday 15 July 2011

php - When in optimization phase, would it be smart to pass all array by ref? -


In PHP, when we optimize the application phase (I'm talking about an app that is thousands of users) (Where does not matter to me what happens after they pass them to the function) will be smart to pass by the referee?

In PHP arrays, copy-on-written words mean that unless it has been modified Until then, new storage is not allocated for the new array. For example:

  $ a = array (1,2,3); $ B = $ A; // $ b digit $ 1 $ b [1] = 4 for memory locations; // $ B is copied and amended  

Passing through the reference can cause a difference if there are too many passes between different approaches and all these are localized Scope is constantly modified, however, it will change the words of the application, which means that this change is possible only if the arrays are not being modified.

This means that there is no use in passing the array as a reference. Do not do that.


No comments:

Post a Comment