Return a value or modify reference?

migueflow

New Member
I've seen both before, and as far as I know, it's pretty much subjective, but if given the option, which would you do and why? If the data were large, would there be any speed/memory benefit to one of them?\[code\]function processData(&$data_to_process) { // Pass by reference. // do something to the data}// ... somewhere else$this->processData($some_data);\[/code\]or\[code\]function processData($data_to_process) { // Pass by value. // do something to the data return $data_to_process;}// ... somewhere else$some_data = http://stackoverflow.com/questions/3644701/$this->processData($some_data);\[/code\]
 
Back
Top