5
I’m practicing some code in PHP when I come across this:
<?php
$a = (object) ["a" => "b"];
$b = (object) ["a" => "c"];
$y = $a <=> $b;
echo $y;
$v=[1,2,3] <=> [1,2,3];
echo $v;
$a= (object) ["a" => "b"];
$b = (object) ["a" => "b"];
echo $a <=> $b;
echo ($y == -1)? 1:0;
?>
Since I haven’t practiced PHP for a long time, my doubts are as follows::
Why the exits of the first three
echo
are being respectively,-1,0,0
?How I do this conversion
["a" => "b"]
type-to-object?What’s the name of it
<=>
? comparison operator? Equality? I searched in thephp.net
I didn’t find anything on that.