1、"&"这种方式就是是"传址", 但由于内部数据结构的原因与c是有区别的,所以称其为“引用” 2、php5的对象默认是传“引用”而不是"传值"。 <?php class foo { var $v = 1; function show() { echo $this->v; } }$a = new foo; $b = $a; $a->show(); //out 1 $a->v = 3; $b->show(); //out 3 for php5 ?> 可见$a和$b是一个东西,而这个代码在php4中执行时$b->show(); 只会输出1
PHP 4 improved the situation. The new version introduced the notion of references, which allowed multiple symbols in PHP's symbol space to actually refer to the same place in memory. This means that you could have two or more names for the same variable, as shown in Listing 6.20.----------------- 才找到的
2、php5的对象默认是传“引用”而不是"传值"。
<?php
class foo {
var $v = 1;
function show() {
echo $this->v;
}
}$a = new foo;
$b = $a;
$a->show(); //out 1
$a->v = 3;
$b->show(); //out 3 for php5
?>
可见$a和$b是一个东西,而这个代码在php4中执行时$b->show(); 只会输出1
才找到的