Lecture
This operator is designed to compare two expressions. It returns -1, 0, or 1 if $ a, respectively, is less than, equal to, or greater than $ b. The comparison is made in accordance with the rules of comparing PHP types.
<? php
// Integers
echo 1 <=> 1; // 0
echo 1 <=> 2; // -one
echo 2 <=> 1; // one
// Rational
echo 1.5 <=> 1.5; // 0
echo 1.5 <=> 2.5; // -one
echo 2.5 <=> 1.5; // one
// Strings
echo "a" <=> "a"; // 0
echo "a" <=> "b"; // -one
echo "b" <=> "a"; // one
?>
Comments
To leave a comment
Running server side scripts using PHP as an example (LAMP)
Terms: Running server side scripts using PHP as an example (LAMP)