PHP returns a link if it is optimal for the interpreter to do this . Usually, the parameters passed to the function are copied, although you pass the parameter by reference and, therefore, get the return value by reference like this:
function blah(&$foo) { $foo = array();//or whatever //note no return statement } //elsewhere $x = "whatever"; blah($x); //$x is now an array.
Because of & , $foo treated as a link, and therefore modifications to this variable are treated as modifications to the link.
Or you can force the function to return the link:
function &blah() {
This last one should not, according to the documents, be fulfilled unless you have a reason for optimization.
However, PHP is not very efficient, and worrying about these things is usually premature - unless you see the actual bottleneck in your code.
source share