关联参数传递的使用方法

2025-12-28 13:41:09

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
?>
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢