Home >Backend Development >PHP Tutorial >The difference between passing parameters in PHP by value and passing address, passing parameters in php_PHP tutorial
Without further ado, let’s look at the code first
function test(&val){ return $val; }
Why is & used to pass parameters? What are the benefits?
Passing by address means allowing changes within the function, for example:
$test = "hello"; function myFun(&$val){ $val = "hello world"; return $val; } echo myFun(&$test); //hello world echo $test; //hello world
The above is the entire content of this article, I hope you all like it.