note 71623 added to language.oop5.object-comparison
| From: | jazfreshathotmail dot com at osu1 dot php dot net | Date: | Fri, 08 Dec 2006 10:36:38 +0000 |
| Subject: | note 71623 added to language.oop5.object-comparison | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120428@lists.php.net to get a copy of this message | ||
Note that when comparing object attributes, the comparison is recursive (at least, it is with PHP
5.2). That is, if $a->x contains an object then that will be compared with $b->x in the same
manner. Be aware that this can lead to recursion errors:
<?php
class Foo {
public $x;
}
$a = new Foo();
$b = new Foo();
$a->x = $b;
$b->x = $a;
print_r($a == $b);
?>
Results in:
PHP Fatal error: Nesting level too deep - recursive dependency? in test.php on line 11
----
Server IP: 210.138.109.182
Probable Submitter: 61.213.152.134 (proxied: Version 1.1-Build_SOL_1126 $Date: 11/10/2005
17:46:0044$(IWSS))
----
Manual Page -- http://www.php.net/manual/en/language.oop5.object-comparison.php
Edit -- https://master.php.net/note/edit/71623
Del: integrated -- https://master.php.net/note/delete/71623/integrated
Del: useless -- https://master.php.net/note/delete/71623/useless
Del: bad code -- https://master.php.net/note/delete/71623/bad+code
Del: spam -- https://master.php.net/note/delete/71623/spam
Del: non-english -- https://master.php.net/note/delete/71623/non-english
Del: in docs -- https://master.php.net/note/delete/71623/in+docs
Del: other reasons-- https://master.php.net/note/delete/71623
Reject -- https://master.php.net/note/reject/71623
Search -- https://master.php.net/manage/user-notes.php