note 95803 added to language.oop5.overloading
| From: | Anonymous at osu1 dot php dot net | Date: | Fri, 22 Jan 2010 14:03:14 +0000 |
| Subject: | note 95803 added to language.oop5.overloading | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165208@lists.php.net to get a copy of this message | ||
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;
?>
----
Server IP: 69.147.83.197
Probable Submitter: 216.240.7.39
----
Manual Page -- http://www.php.net/manual/en/language.oop5.overloading.php
Edit -- https://master.php.net/note/edit/95803
Del: integrated -- https://master.php.net/note/delete/95803/integrated
Del: useless -- https://master.php.net/note/delete/95803/useless
Del: bad code -- https://master.php.net/note/delete/95803/bad+code
Del: spam -- https://master.php.net/note/delete/95803/spam
Del: non-english -- https://master.php.net/note/delete/95803/non-english
Del: in docs -- https://master.php.net/note/delete/95803/in+docs
Del: other reasons-- https://master.php.net/note/delete/95803
Reject -- https://master.php.net/note/reject/95803
Search -- https://master.php.net/manage/user-notes.php