PHP 7 | Spaceship Operator Last Updated : 21 Jun, 2019 Comments Improve Suggest changes Like Article Like Report This article will make you aware of a very useful operator i.e the spaceship operator PHP 7. The spaceship operator or combined comparison operator is denoted by "<=>". This is a three-way comparison operator and it can perform greater than, less than and equal comparison between two operands. This operator has similar behavior like strcmp() or version_compare(). This operator can be used with integers, floats, strings, arrays, objects, etc. This <=> operator offers combined comparison : Return 0 if values on either side are equal Return 1 if value on the left is greater Return -1 if the value on the right is greater Example: // Comparing Integers echo 1 <=> 1; // outputs 0 echo 3 <=> 4; // outputs -1 echo 4 <=> 3; // outputs 1 // String Comparison echo "a" <=> "a"; // outputs 0 echo "m" <=> "y"; // outputs -1 echo "y" <=> "c"; // outputs 1 PHP <?php echo"Integers \n"; echo 7 <=> 7 ; echo"\n"; echo 7 <=> 6; echo"\n"; echo 6 <=> 7; echo"\nFloat\n"; echo 2.5 <=> 1.5; echo"\n"; echo 0.5 <=> 1.5; echo"\n"; echo 1.5 <=> 1.5; echo"\nStrings\n"; echo "a" <=> "a" ; echo"\n"; echo "g" <=> "b" ; echo"\n"; echo "a" <=> "b" ; echo"\nArrays\n"; echo [] <=> []; echo"\n"; echo [1, 7, 3] <=> [1, 7, 3]; echo"\n"; echo [1, 7, 3, 5] <=> [1, 7, 3]; echo"\n"; echo [1, 7, 3] <=> [4, 4, 4]; echo"\n"; ?> Output: Integers 0 1 -1 Float 1 -1 0 Strings 0 1 -1 Arrays 0 0 1 -1 Reference:http://php.net/manual/en/language.operators.comparison.php Comment More infoAdvertise with us Next Article PHP 7 | Spaceship Operator S sid4321 Follow Improve Article Tags : Misc Web Technologies PHP PHP-function PHP-Operators +1 More Practice Tags : Misc Similar Reads PHP Operators In PHP, operators are special symbols used to perform operations on variables and values. Operators help you perform a variety of tasks, such as mathematical calculations, string manipulations, logical comparisons, and more. Understanding operators is essential for writing effective and efficient PH 8 min read Perl | Operators | Set - 2 Operators are the main building block of any programming language. Operators allow the programmer to perform different kinds of operations on operands. In Perl, operators symbols will be different for different kind of operands(like scalars and string). Some of the operators already discussed in Per 7 min read Perl | Operators | Set - 1 Operators are the main building block of any programming language. Operators allow the programmer to perform different kinds of operations on operands. In Perl, operators symbols will be different for different kind of operands(like scalars and string). Operators Can be categorized based upon their 12 min read Perl | String Operators Operators are the foundation of any programming language. Thus, the functionality of Perl programming language is incomplete without the use of operators. A user can define operators as symbols that help to perform specific mathematical and logical computations on operands. String are scalar variabl 4 min read PHP | Bitwise Operators The Bitwise operators is used to perform bit-level operations on the operands. The operators are first converted to bit-level and then calculation is performed on the operands. The mathematical operations such as addition , subtraction , multiplication etc. can be performed at bit-level for faster p 5 min read String Operators | Shell Script Pre-Requisite: Conditional Statement in Shell Script There are many operators in Shell Script some of them are discussed based on string. Equal operator (=): This operator is used to check whether two strings are equal. Syntax:Operands1 = Operand2Example:Â php #!/bin/sh str1="GeeksforGeeks"; str2="ge 2 min read PHPUnit: Testing Framework for PHP PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks. It is used for the purpose of unit testing for PHP code. PHPUnit was created by Sebastian Bergmann and its development is hosted on GitHub.Purpose of the PHPUnit Frame 2 min read PHP | AppendIterator valid() Function The AppendIterator::valid() function is an inbuilt function in PHP which is used to check the validity of the current element. Syntax: bool AppendIterator::valid( void ) Parameters: This function does not accept any parameters. Return Value: This function returns TRUE if the current iteration is val 1 min read PHP strnatcasecmp() Function The strnatcasecmp() function is a built-in function in PHP which compares this string using "natural order" algorithm. This function accepts two strings as parameter and returns an integer value (positive, negative or zero ). This function is similar to strnatcmp() with the only difference being the 2 min read PHP 5 vs PHP 7 PHP is a server-side scripting language designed for web development by Rasmus Lerdorf in 1994. Since its launch in 1994, PHP has become an industry standard, supporting almost 80% of the websites (79.8% to be precise) with its closest competitor being ASP.Net at 19.8% and others like Ruby, Java tra 3 min read Like