Spaceship Always False¶
<?php
class A {}
class B {}
$a = new A;
$b = new B;
var_dump($a <=> $b); // 1: A > B
var_dump($b <=> $a); // 1: B > A
var_dump($b == $a); // false
Compare A to B, and A is bigger than B.
Compare B to A, and B is bigger than A.
And, in the end, they are still different.
See Also¶
Comparing two objects [Try me]
PHP Features¶
Last updated: 14 July 2026