From 085b99faeb13a69ee8b15fad6a7d3746b348ee33 Mon Sep 17 00:00:00 2001 From: Rich Date: Wed, 31 Oct 2018 23:20:20 +0000 Subject: [PATCH] PHP spaceship operator (#32991) --- guide/english/php/operators/index.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/guide/english/php/operators/index.md b/guide/english/php/operators/index.md index 48aca3077c..23d37e48d2 100644 --- a/guide/english/php/operators/index.md +++ b/guide/english/php/operators/index.md @@ -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 + 1; // 0 +echo 1 <=> 2; // -1 +echo 2 <=> 1; // 1 + +```