note 95803 deleted from language.oop5.overloading by thiago
| From: | thiago@php.net | Date: | Fri, 22 Jan 2010 14:04:33 +0000 |
| Subject: | note 95803 deleted from language.oop5.overloading by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165209@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
Franz, the documentation doesn't say assignment chaining doesn't work, it simply says that
the return value of __set() is ignored during chaining, and that __get() is never called.
Given:
<?php
class Doubler {
function __set($field, $value) {
return $this->$field = $value * 2;
}
function __get($field) {
return $this->$field;
}
}
$d = new Doubler();
$x = $d = 7;
?>
You might expect $x to be 14, and in many languages it would be 14, but the return value of __set()
is ignored and instead the statement is equivalent to
<?php
$x = 7;
$d = 7;
?>