Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php 8 major changes - Nullsafe operator

BEFORE
$country =  null;

if ($session !== null) {
  $user = $session->user;

  if ($user !== null) {
    $address = $user->getAddress();
 
    if ($address !== null) {
      $country = $address->country;
    }
  }
}
AFTER
$country = $session?->user?->getAddress()?->country;
Source by www.php.net #
 
PREVIOUS NEXT
Tagged: #php #major #Nullsafe #operator
ADD COMMENT
Topic
Name
3+7 =