PHP spaceship operator (#32991)

pull/33960/head
Rich 2018-10-31 23:20:20 +00:00 committed by Paul Happ
parent 6f05fd928c
commit 085b99faeb
1 changed files with 12 additions and 0 deletions

View File

@ -12,3 +12,15 @@ A single “=” is used as the assignment operator and a double “==” or tri
The usual “<” and “>” can also be used for comparison and “+=” can be used to add a value and assign it at the same time.
Most notable is the use of the “.” to concatenate strings and “.=” to append one string to the end of another.
New to PHP 7.0.X is the Spaceship operator (<=>).
The spaceship operator returns -1, 0 or 1 when $a is less than, equal to, or greater than $b.
```php
<?php
echo 1 <=> 1; // 0
echo 1 <=> 2; // -1
echo 2 <=> 1; // 1
```