它意味着通过引用传递变量,而不是传递变量的值.这意味着当程序流返回到调用代码时,preparse_tags函数中对该参数的任何更改都将保留.
function passByReference(&$test) {
$test = "Changed!";
}
function passByValue($test) {
$test = "a change here will not affect the original variable";
}
$test = 'Unchanged';
echo $test . PHP_EOL;
passByValue($test);
echo $test . PHP_EOL;
passByReference($test);
echo $test . PHP_EOL;
Run Code Online (Sandbox Code Playgroud)
输出:
Unchanged
Unchanged
Changed!
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1109 次 |
| 最近记录: |