PHP 7 Spaceship Operator

Spaceship Operator has been introduced in PHP 7.It returns -1, 0 or 1 when varible $a is respectively less than, equal to, or greater than varible $b.

Syntax

$a <=> $b;
<?php

//integer comparison
print( 2 <=> 2)."<br/>";
print( 2 <=> 3)."<br/>";
print( 3 <=> 2)."<br/>";
print("
"); //float comparison print( 2.5 <=> 2.5)."<br/>"; print( 1.5 <=> 2.5)."<br/>"; print( 3.5 <=> 2.5)."<br/>"; print("
"); //string comparison print( "a" <=> "a")."<br/>"; print( "a" <=> "b")."<br/>"; print( "b" <=> "a")."<br/>"; ?>

OutPut

The above example will output: 
0
-1
1

0
-1
1

0
-1
1