20
I was just taking a look at the New Features of PHP 7 and I came across an operator, who I had never seen in any programming language. The PHP Handbook demonized him of Spaceship Operator
.
I’ll demonstrate them below what I saw:
echo 1 <=> 1; // 0
echo 1 <=> 2; // -1
echo 2 <=> 1; // 1
I don’t know if I got it right, but it seems to me he does the same thing as strcmp
.
- After all, simply, what is the purpose of this operator?
- What are the advantages gained by using it?
I was waiting for that question :D
– rray
And you were hoping I’d ask?
– Wallace Maxters