Optional chaining is not supported in php ( ?. operator ) But you can use something like this if ($a && $a->$b && $a->$b->$c) { $d = $a->$b->$c; } $d = $a?->$b?->$c; // assigns null to $d upon failure