Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator
[email protected] (Sherif Ramadan)
| Newsgroups | php.internals |
|---|---|
| Message-ID | <CAL+t6cH_nGq=5P2_RxRMK7cxY3n3jNDHREAZJug21fvk0P_8rA@mail.gmail.com> |
On Mon, Sep 8, 2014 at 4:06 AM, Michael Wallner <[email protected]> wrote: > On 07/09/14 14:25, Andrea Faulds wrote: > > > > > There’s actually a quite serious issue just now, which is that it > > evaluates the first operand twice if it’s not empty. This is because > > $a ?: $b is expanded to empty($a) ? $b : $a, such that if you did > > something which mutates state in there, it’d happen twice. This is > > obviously not good, and I’m going to figure out how to fix this. > > > > This could very well be the reason why it is like it is today. > > I agree. The more I think about, the more this seems weird. What if I explicitly want to use ternary to check isset() and not empty?