关联参数传递的使用方法

时间:2026-02-18 15:14:01

1、方法一:


functionfoo(&$bar){
$bar.="andsomethingextra";
}
$str="ThisisaString,";
foo($str);
echo$str;//output:ThisisaString,andsomethingextra

echo"<br>";

关联参数传递的使用方法

2、方法二:


functionfoo1($bar){
$bar.="andsomethingextra";
}
$str="ThisisaString,";

foo1($str);


echo$str;//output:ThisisaString,

echo"<br>";

foo1(&$str);


echo$str;//output:ThisisaString,andsomethingextra
?>

© 2026 一点知道
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com