Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Spaceship Always False

By Jerome Tamarelle

<?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

PHP Features

Last updated: 10 September 2026