时间:2021-07-01 10:21:17 帮助过:50人阅读
<?php 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.
如果没有这个&符号,
<?php 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,
以上就是PHP通过引用传递参数用法分析 的内容,更多相关内容请关注PHP中文网(www.gxlcms.com)!