Why this only print out "-1". What happens to the first part of the text.
echo "2 results of this " . "Apples" <=> "bananas";
Thanks
Why this only print out "-1". What happens to the first part of the text.
echo "2 results of this " . "Apples" <=> "bananas";
Thanks
.
has higher precedence than <=>
, so it's parsed as if you'd written:
echo ("2 results of this " . "Apples") <=> "bananas";
which is equivalent to:
echo "2 results of this Apples" <=> "bananas";
So it's comparing these two strings and printing just the result.
Add parentheses to get what you want:
echo "2 results of this " . ("Apples" <=> "bananas");