Hi Bruce

If I understand correctly.

$_SERVER['fname'] !?? $user->setName($_SERVER['fname']);


Will return the result of  $user->setName($_SERVER['fname']) if
$_SERVER['fname']  is set or null if not set. While:

isset($_SERVER['fname']) && $user->setName($_SERVER['fname']);


Will return boolean.

Cheers

On Fri, Oct 25, 2019 at 4:24 AM Bruce Weirdan <weir...@gmail.com> wrote:

> Hi Ken
>
> >         $_SERVER['fname'] !?? $user->setName($_SERVER['fname']);
> >         $_SERVER['lname'] !?? $user->setName($_SERVER['lname']);
> >         $_SERVER['mname'] !?? $user->setName($_SERVER['mname']);
> >         $_SERVER['phone'] !?? $user->setName($_SERVER['phone']);
> >         $_SERVER['email'] !?? $user->setName($_SERVER['email']);
>
> What you described is already achievable with short-circuit && :
>
>   isset($_SERVER['fname']) && $user->setName($_SERVER['fname']);
>
> Besides, it's a widely used idiom known from shell scripting.
>
> --
>   Best regards,
>       Bruce Weirdan                                     mailto:
> weir...@gmail.com
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to