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

From: Date: Wed, 17 Sep 2014 08:58:32 +0000
Subject: Re: [RFC] Implicit isset() in Shorthand Ternary Operator
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14  Groups: php.internals 
Request: Send a blank email to internals+get-77281@lists.php.net to get a copy of this message
> On Sep 16, 2014, at 13:46, "Kingsquare.nl - Robin Speekenbrink" > <robin@kingsquare.nl> wrote: > > As a userland point of view on this: will this have a shorthand? i.e. > what will happen if i leave out the second part? > > ie. > $var = $_GET['test'] ?? ; > > would that be the same as > $var = @$_GET['test']; > > The RFC isnt clear in this regard (or that the righthand side of the > operator _is_ required... maybe it's me ? > The equivalent of your error suppressed example would be: $var = $_GET['test'] ?? null; I don't think it gains anyone much to have another form just to save four characters (for the default null). Someone mentioned an assignment version which isn't covered in niki's patch but would be a fairly trivial addition. $var ??= expr; Which essentially means: if (!isset($var)) { $var = expr; } I'd kinda like that for completeness, but will vote for this with or without the assignment version. -Sara

« previous php.internals (#77281) next »