Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparison operator overloading in php

Tags:

php

Is it possible to overload the ==/!= operators in php, similar to the way it's done in .NET?

like image 947
mikej Avatar asked Jun 24 '10 15:06

mikej


2 Answers

http://pecl.php.net/package/operator

see this as well:

http://webreflection.blogspot.com/2008/06/from-future-php-javascript-like-number.html

like image 176
Spencer Avatar answered Oct 04 '22 06:10

Spencer


Just for reference (as this identical question has been asked several times today), nikic has just posted details of a Comparable interface that overloads comparison operators for objects - https://github.com/nikic/comparable

like image 28
Mark Baker Avatar answered Oct 04 '22 05:10

Mark Baker