亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Reference to parameters of php custom function

In the variable function, we have learned about variable references. Let’s review the knowledge:

<?php

$a = 10;

$b = &$a;

$a = 100;

echo $a.'---------'.$b;
?>

The appeal knowledge points are in the variable chapter. Variable references are described. It means that variables $a and $b point to the same storage location to store values.

The parameter reference of the function also has the same meaning, pointing the formal parameters and actual parameters to the same location. If the formal parameters change within the function body, the values ??of the actual parameters also change. Let's see through experiments:

<?php

$foo = 100;

//注意:在$n前面加上了&符
function demo(&$n){

       $n = 10;

       return $n + $n;

}

echo  demo($foo).'<br />';

//你會(huì)發(fā)生$foo的值變?yōu)榱?0
echo $foo;

?>

Through the above example, we found that the actual parameter is $foo. When calling the demo, let $foo and $n point to the same storage area. When $n's When the value changes. Then the value of $foo also changes.


Continuing Learning
||
<?php $foo = 100; //注意:在$n前面加上了&符 function demo(&$n){ $n = 10; return $n + $n; } echo demo($foo).'<br />'; //你會(huì)發(fā)生$foo的值變?yōu)榱?0 echo $foo; ?>
submitReset Code