I have a method in one of my classes that will in some cases be passed an enormous value as a parameter. I was thinking that if this were C++, I might want to pass that parameter by reference to avoid piling it all on the stack:
public function foo(&$huge_param) {
// do some stuff blah blah
return $this->bar();
}
HOWEVER, the php documentation says:
PHP Docs wrote:Returning by reference is useful when you want to use a function to find to which variable a reference should be bound. Do not use return-by-reference to increase performance. The engine will automatically optimize this on its own. Only return references when you have a valid technical reason to do so.
I'm thinking I should not be calling by reference to try and speed things up. Is that right?