Remembering what spaceship operator do on comparison in PHP
February 20, 2020 — PHP has introduced an operator called “spaceship opearator” (<=>
) with the release of PHP7. What this spaceship operator do is compare two expressions i.e. its two operands, let’s say $a
and $b
, and returns -1, 0 or 1 when $a
is respectively less than, equal to, or greater than $b
.