Exponential operator
echo 10 ** 2; // 10^2 = 100Spaceship Operator
Return 0 if values on either side are equal
Return 1 if the value on the left is greater
Return -1 if the value on the right is greater// Comparing Integers
echo 1 <=> 1; // 0
echo 3 <=> 4; // -1
echo 4 <=> 3; // 1
// Comparing Strings
echo "x" <=> "x"; // 0
echo "x" <=> "y"; // -1
echo "y" <=> "x"; // 1Null safe Operator
Discards everything after the question mark if the expression before the question mark evaluates to null
$foo = null;
echo $foo?->bar(); // Will not throw an errorNull coalescing Operator
$x = null;
echo $x ?? "Hello"; // Hello
// Equivalent to:
echo isset($x) ? $x : "Hello";Splat Operator
Used in functions to accept an undefined number of arguments
function sum(...$numbers)
{
return array_sum($numbers);
}
sum(1, 2, 3, 4); // 10
// Also works:
sum(1, 2, ...[3, 4]); // 10