Em qua., 24 de fev. de 2021 às 12:29, Michael Morris <tendo...@gmail.com> escreveu:
> Javascript has this now though support isn't widespread. > > > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining > > The most similar way to do it in PHP would be ?-> > Optional chaining is not the same. My suggestion is similar to: $variable = $user->exists ? $user->fullname; // suggestion (will return null if expression is falsy) $variable = $user->exists ? $user->fullname : null; // same as Optional chaining is: $variable = $user?->exists; // PHP 8 $variable = $user && $user->exists ? true : null; // same as