PHP 7

Whats new in php 7 ? new functions in php 7 

Null Coalesce Operator

What is Null Coalesce Operator which is newly introduced in php 7 ?

// ?? operator

$name = $firstName ??  "Guest";

if the value is set to not null or if value exist in the left it will return the left side value ($firstname),

if the value is null and not defined in left it will return the right side value ("Guest"),

Note: it will not through notice if $firstName variable is not defined or non-existent.

 

And you know what it is equivalent to 

Spaceship operator

What is Spaceship Operator which is newly introduced in php 7

// <=> Space ship Operators

$compare = 2 <=> 1
2 < 1? return -1
2 = 1? return 0
2 > 1? return 1

When its a combination 3 operators.less than, equals and greater than,

When the value on the left is less than the value on the right, it will return -1,

When the value on the left and right is equal it will  return 0,