note 102204 added to language.oop5.object-comparison
| From: | SjH at osu1 dot php dot net | Date: | Wed, 02 Feb 2011 12:15:49 +0000 |
| Subject: | note 102204 added to language.oop5.object-comparison | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-176593@lists.php.net to get a copy of this message | ||
Interestingly enough due to the operator precidences changing the values of identical objects may
not be as obvious as expected.
<?php
class A {
private $val;
public function set($val)
{
$this->val = $val;
return $this;
}
}
$a = new A;
$b = new A;
$c = $a;
echo var_dump($a->set('foo') == $b->set('bar'));
// Will evaluate as boolean false
echo var_dump($a->set('foo') == $c->set('bar'));
// Will evaluate a boolean true
?>
----
Server IP: 69.147.83.197
Probable Submitter: 82.18.86.179
----
Manual Page -- http://www.php.net/manual/en/language.oop5.object-comparison.php
Edit -- https://master.php.net/note/edit/102204
Del: integrated -- https://master.php.net/note/delete/102204/integrated
Del: useless -- https://master.php.net/note/delete/102204/useless
Del: bad code -- https://master.php.net/note/delete/102204/bad+code
Del: spam -- https://master.php.net/note/delete/102204/spam
Del: non-english -- https://master.php.net/note/delete/102204/non-english
Del: in docs -- https://master.php.net/note/delete/102204/in+docs
Del: other reasons-- https://master.php.net/note/delete/102204
Reject -- https://master.php.net/note/reject/102204
Search -- https://master.php.net/manage/user-notes.php