Since PHP objects are passed by reference(reference to the object itself, not to be confused with reference to the variable), does passing a very large object to a function add any resource stress to the system?
This seems like a 'get out of jail free card' for passing information, Since no copies are being made, I can pass a huge object around, while if I pass an array I take a memory hit.
In my OOP coding style, I prefer passing entire objects as arguments instead of just a single attribute, as it makes the code more readable and allows for greater functionality down the road if it's needed.
So my questions :
- Am I correct in my assumption that objects infer no resource hit when passed to functions?
- Does this scale? Is passing a 1MB object any different than passing a 10MB object?
- Is accessing an object attribute the same as accessing an array key? Is there a performance issue involved?
Thanks in advance!
memory_get_usage.