Skip to content

Instantly share code, notes, and snippets.

@lechidung
Last active November 29, 2020 18:18
Show Gist options
  • Select an option

  • Save lechidung/67482b879136b5e3edbe7b770cda6192 to your computer and use it in GitHub Desktop.

Select an option

Save lechidung/67482b879136b5e3edbe7b770cda6192 to your computer and use it in GitHub Desktop.
PHP 8
/*** PHP 7 ***/
$country = null;
if ($session !== null) {
$user = $session->user;
if ($user !== null) {
$address = $user->getAddress();
if ($address !== null) {
$country = $address->country;
}
}
}
/*** PHP 8 ***/
$country = $session?->user?->getAddress()?->country;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment