What is Null Safety Operator in PHP8?

Null Safe Operator is a new way to check null and get non null value. For example, before PHP8.0 if we needed to check for null values and get rid of them we needed to do this. 

$city = null; 
if($user !== null) 
{ 
      $address = $user->getAddress(); 
      if($address !== null) 
      { 
            $city = $address->city; 
       }
}

Now if we use null coalescing operator then we can get the same results but a few lines shorter. 

$city = null; 
if($user !== null) 
{ 
     $city = $user->getAddress()->city ?? null; 
}

But with the new null safe operator we can get the same results in one line. 

$city = $user?->getAddress()?->city