Source Code:
(back to article)
<?php class pupil { public $value = 42; public function &getValue() { return $this->value; } } $obj = new pupil(); // $myValue is a reference to // $obj->value, which is 42. $myValue = &$obj->getValue(); $obj->value = 2; // Printing the new value of // $obj->value, i.e. 2. echo $myValue; ?>
Result:
Report an issue