note 81600 added to language.oop5.object-comparison
| From: | cross+php at distal dot com | Date: | Wed, 05 Mar 2008 16:50:44 +0000 |
| Subject: | note 81600 added to language.oop5.object-comparison | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136766@lists.php.net to get a copy of this message | ||
In response to "rune at zedeler dot dk"s comment about class contents being equal, I have
a similar issue. I want to sort an array of objects using sort().
I know I can do it with usort(), but I'm used to C++ where you can define operators that allow
comparison. I see in the zend source code that it calls a compare_objects function, but I
don't see any way to implement that function for an object. Would it have to be an extension
to provide that interface?
If so, I'd like to suggest that you allow equivalence and/or comparison operations to be
defined in a class definition in PHP. Then, the sorts of things rune and I want to do would be much
easier.
----
Server IP: 208.69.120.35
Probable Submitter: 66.16.13.2
----
Manual Page -- http://www.php.net/manual/en/language.oop5.object-comparison.php
Edit -- https://master.php.net/note/edit/81600
Del: integrated -- https://master.php.net/note/delete/81600/integrated
Del: useless -- https://master.php.net/note/delete/81600/useless
Del: bad code -- https://master.php.net/note/delete/81600/bad+code
Del: spam -- https://master.php.net/note/delete/81600/spam
Del: non-english -- https://master.php.net/note/delete/81600/non-english
Del: in docs -- https://master.php.net/note/delete/81600/in+docs
Del: other reasons-- https://master.php.net/note/delete/81600
Reject -- https://master.php.net/note/reject/81600
Search -- https://master.php.net/manage/user-notes.php