调用函数之前,我的名字叫 :'.$girl;
changeName($girl);
echo'
调用函数之后,我的名字叫:'.$girl;
// Test transmit the array parameters by reference
function addPrice(&$price)
{
$price[0]+=20;
$price[1]+=30;
$price[2]+=25;
}
function discount(&$price)
{
foreach ($price as $key=> $aa)
{
$aa*=.8;
$price[$key]*=.8;
}
}
function priceSet(&$price)
{
$price[0]=20;
$price[1]=30;
$price[2]=25;
}
echo '
';
$price_a=array(100,29,30);
echo'
before discount the price is ';
var_dump($price_a);
discount($price_a);
echo '
after discount the price is ';
var_dump($price_a);
$price_a=array(100,29,30);
addprice($price_a);
echo '
after add the price is ';
var_dump($price_a);
$price_a=array(100,29,30);
priceset($price_a);
echo '
after set the price is ';
var_dump($price_a);
echo '
启科网络商城系统由启科网络技术开发团队完全自主开发,使用国内最流行高效的PHP程序语言,并用小巧的MySql作为数据库服务器,并且使用Smarty引擎来分离网站程序与前端设计代码,让建立的网站可以自由制作个性化的页面。 系统使用标签作为数据调用格式,网站前台开发人员只要简单学习系统标签功能和使用方法,将标签设置在制作的HTML模板中进行对网站数据、内容、信息等的调用,即可建设出美观、个性的网站。
0
';
function setinfo (&$people)
{
$people['name']='momomo';
$people['age']=20;
$people['hobby']='reading';
}
$gril=array('name'=>'xiao mo mo','age'=>18,'hobby'=>'studing');
echo '
before called the function ,the value is ';
var_dump($gril);
setinfo($gril);
echo '
after called the function ,the array value is ';
var_dump($gril);
?>
运行结果:
调用函数之前,我的名字叫 :mo
调用函数之后,我的名字叫:xiao huihui
before discount the price is array(3) { [0]=> int(100) [1]=> int(29) [2]=> int(30) }
after discount the price is array(3) { [0]=> float(80) [1]=> float(23.2) [2]=> float(24) }
after add the price is array(3) { [0]=> int(120) [1]=> int(59) [2]=> int(55) }
after set the price is array(3) { [0]=> int(20) [1]=> int(30) [2]=> int(25) }
before called the function ,the value is array(3) { ["name"]=> string(10) "xiao mo mo" ["age"]=> int(18) ["hobby"]=> string(7) "studing" }
after called the function ,the array value is array(3) { ["name"]=> string(6) "momomo" ["age"]=> int(20) ["hobby"]=> string(7) "reading" }
CSDN大法好。小菜鸟求教了。
您不觉得那位作者太想当然了吗?
这种治学态度写的书能看吗?
版主推荐一些差不多的PHP学习书呗。谢谢了。
《PHP从入门到精通》中,讲对数组变量按引用传递时,只是传递了数组首个元素的地址。 因此退出函数后,只有对首个元素的修改是有效的。
?色部分明?是?的。
看完?,??,??一下。
谢谢了。
书上错的真离谱。
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号