php引用详解
<?php
function foo($bar){
? $bar='111111111';
}
$str='2222222222222';
foo($str);
echo $str; //output is 2222222222222
$str2='xxxxxxxxxxxx詳詳細細2222222222222';
foo(&$str2);
echo $str2; //output is 111111111
//即使函數的參數定義不是&$arg,引用傳過去也能修改原值
function foo(&$bar){
? $bar='111111111';
}
$str='2222222222222';
foo($str);
echo $str; //output is 111111111
$str2='xxxxxxxxxxxx詳詳細細2222222222222';
foo(&$str2);
echo $str2; //output is 111111111
//函數定義了&arg參數,傳的時候使用&$arg工作仍然正常
?>?
轉載于:https://www.cnblogs.com/Alight/p/3718551.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
- 上一篇: java定时任务,每天定时执行任务
- 下一篇: php执行外部命令