The difference between value-passing and address-passing in PHP parameter passing, PHP parameter passing
Without further ado, let’s look at the code first
function test(&val){
return $val;
}
Copy after login
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
Copy after login
The above is the entire content of this article, I hope you all like it.
http://www.bkjia.com/PHPjc/989569.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/989569.htmlTechArticleThe difference between value-passing and address-passing in PHP parameter passing. Not much nonsense about PHP parameter passing. Let’s look at the paragraph first. Code function test(} Why is function myFun(return $val;}echo myFun( //hello worldecho...