开发者

Comparison operator overloading in php

开发者 https://www.devze.com 2023-01-04 10:54 出处:网络
Is it possible to overload the ==/!= operators开发者_开发百科 in php, similar to the way it\'s done in .NET?http://pecl.php.net/package/operator

Is it possible to overload the ==/!= operators开发者_开发百科 in php, similar to the way it's done in .NET?


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

see this as well:

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


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


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

精彩评论

暂无评论...
验证码 换一张
取 消