传递方式
调用函数func($str)
定义函数function func(&$str)
注意使用方式!
使用错误会提示:Call-time pass-by-reference has been removed....
看一段别人的例子:
function add_some_extra(&$string) // 引入变量,使用同一个存储地址
{
$string .= 'and something extra.';
}
$str = 'This is a string, ';
add_some_extra($str);
echo $str; // outputs 'This is a string, and something extra.'
}
输出结果:This is a string,and something extra.
function add_some_extra($string) {
$string .= 'and something extra.';
}
$str = 'This is a string, ';
add_some_extra($str);
echo $str; // outputs 'This is a string, '
输出结果:This is a string,