mikej
mikej

Reputation: 105

Comparison operator overloading in php

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

Upvotes: 6

Views: 8741

Answers (3)

Mark Baker
Mark Baker

Reputation: 212522

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

Upvotes: 2

Pik'
Pik'

Reputation: 7097

No, unfortunately you can't. You should create a class or member function.

Edit : oh, didn't know about this PECL package ! I should try it. :)

Upvotes: 0

Related Questions