$user = null; echo $user->address->country ?? ''; PHPのプロパティは元よりnull安全なので、存在しないプロパティだろうがnullだろうがプリミティブ型だろうがいきなりプロパティを取り出せます。 取れない場合はE_NOTICEが発生しますが、??を使えば黙殺できます。 しかしメソッドはだめです。 echo $user->getAddress()->getCountry() ?? ''; // Fatal error: Call to a member function getAddress() // 1 if (method_exists($user, 'getAddress')) { if (method_exists($user->getAddress(), 'getCountry')) { echo $user->getAddres
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く