首页 > Web开发 > 详细

php引用详解

时间:2014-05-10 00:47:22      阅读:414      评论:0      收藏:0      [点我收藏+]

<?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工作仍然正常
?> 

php引用详解,布布扣,bubuko.com

php引用详解

原文:http://www.cnblogs.com/Alight/p/3718551.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!