测试1
function add($a)
{ $a+=1; echo $a."<hr>";}$a = 1;add($a);echo $a输出:
1
1
测试2
function add($a)
{ $a+=1; echo $a."<hr>";}$a = 1;add(& $a);echo $a输出虽然达到了效果,但是会报错
Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of add(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file in path on line 8
2
2
测试3
function add(& $a)
{ $a+=1; echo $a."<hr>";}$a = 1;add($a);echo $a结果
2
2
这个才是正确的