note 83456 deleted from language.oop5.overloading by danielc

From: Date: Fri, 28 Aug 2009 03:37:43 +0000
Subject: note 83456 deleted from language.oop5.overloading by danielc
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-159973@lists.php.net to get a copy of this message
Note Submitter: uramihsayibok, gmail, com Reason: 0 ---- Expanding in part on what Hayley Watson said (5 Feb 2008) regarding $a=$b=$c: My first impression was that <?php $a=$foo->var=$c; ?> would assign $c to $foo->var (by using __set) and the *return value* of __set would be assigned to $a - like what happens in other languages. Perhaps the default (if __set returns void/null) would be $c. This is not the case. The code above is equivalent to <?php $foo->var=$c; $a=$c; ?>. Regardless of what __set returns, $a will always have the value of $c. <?php class Foo { public function __set($name,$value) { static $var; $var=$value; // return "abc"; // comment, uncomment at will } } $f=new Foo(); $g=($f->var="value"); echo $g; // $g is always "value", even if the return above is uncommented ?>

« previous php.notes (#159973) next »