<?php class foo { public $value = 42; public function &getValue() { return $this->value; } } $obj = new foo; // $myValue is a reference to $obj->value, which is 42. // $myValue 是 $obj->value 的引用,它们的值都是 42 $myValue = &$obj->getValue(); // 对 $obj->value 重新复制,会影响到 $myValue 的值 $obj->value = 2; // prints the new value of $obj->value, i.e. 2. echo $myValue; // 程序输出 2 ?>