Re: [Proposal] Modification to ?: functionality

From: Date: Tue, 26 Nov 2013 15:32:27 +0000
Subject: Re: [Proposal] Modification to ?: functionality
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-70405@lists.php.net to get a copy of this message
Hi, Am Dienstag, 26. November 2013 um 16:15 schrieb Mats Lindh: > On Tue, Nov 26, 2013 at 3:43 PM, Chris London <me@chrislondon.co > (mailto:me@chrislondon.co)> wrote: > > following would be functionally equivalent: > > > > $foo = isset($foo) && $foo ? $foo : 'default'; > > > > $foo = $foo ?: 'default'; > > The would break the assumption that a reference to an uninitialized value > would generate a notice, unless explicitly handled in the logic. > > While I also would like to have something similar to ?: to handle default > values for array keys, etc., this would change a fundamental assumption > that as been in place for many years now. I'm not sure if that's a BC break > that would be acceptable this late. An alternative operator may be more > suitable. Since the discussion about it is quite vivid at the moment: wouldn’t this be a nice candidate for one of the changes in the next major version? -- Cheers Jannik

« previous php.internals (#70405) next »