Re: [RFC] Implicit isset() in Shorthand Ternary Operator

From: Date: Tue, 09 Sep 2014 00:16:47 +0000
Subject: Re: [RFC] Implicit isset() in Shorthand Ternary Operator
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-77108@lists.php.net to get a copy of this message
On Tue, Sep 9, 2014 at 3:07 AM, Andrea Faulds <ajf@ajf.me> wrote: > > On 8 Sep 2014, at 23:58, Adam Harvey <aharvey@php.net> wrote: > >> +1 on ?? — there's precedent for it, and it means we don't have to >> explain why the shorthand form of an operator behaves differently to >> the long form, which is just going to confuse users. > > FWIW, it already behaves differently: > > oa-res-27-90:~ ajf$ php -r 'function foo() { echo "foo\n"; return true; } $x > = foo() ?: false;' > foo > oa-res-27-90:~ ajf$ php -r 'function foo() { echo "foo\n"; return true; } $x > = foo() ? foo() : false;' > foo > foo That's arguable ... I'd say that ($x = foo()) ? $x : false; is the logical equivalent of your first example. Cheers, Andrey.

« previous php.internals (#77108) next »