Comparison operator overloading in php

前端 未结 3 1841
抹茶落季
抹茶落季 2020-12-18 08:02

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

相关标签:
3条回答
  • 2020-12-18 08:41

    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

    0 讨论(0)
  • 2020-12-18 08:41

    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. :)

    0 讨论(0)
  • 2020-12-18 08:44

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

    see this as well:

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

    0 讨论(0)
提交回复
热议问题