PHP 7 Feature Freeze

Spaceship Operator
This RFC adds a new operator (<=>) for combined comparison. Similar to strcmp() or version_compare() in behavior, but it can be used on all generic PHP values with the same semantics as <, <=, ==, >=, >.

This is not something I’d use regularly, but it is certainly not useless as some have said. The three-way comparison operator is useful for sorting, and that is about it.

A lot of people would have liked this to be a function instead. I naively argued that an operator skips the overhead of a function call, but apparently there have been some gains in the PHP engine that bring that difference from trivial to now more like non-existent.

About the author: admin

Leave a Reply

Your email address will not be published.Email address is required.