Re: what happened to that new isset() like language

From: Date: Thu, 08 Jul 2004 16:31:18 +0000
Subject: Re: what happened to that new isset() like language
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-10985@lists.php.net to get a copy of this message
On Thu, 8 Jul 2004, Marc Richards wrote: > Christian Schneider wrote: > > > Before it gets forgotten: I still think that > > $x = ifsetor(mixed var, mixed var [, ...]); > > with expressions in all parts is the way to go. > > > > Example usage: > > $a = ifsetor($_REQUEST['x'], $db->get('x'), 'default_x'); > > > > The other syntax could work for that as well... > > $a = $_REQUEST['x'] ?: $db->get('x') ?: 'default_x'; > > > and with a little white-space it is even more readable: > > $a = $_REQUEST['x'] ?: $db->get('x') ?: 'default_x'; That syntax is way too confusing. Spotting the difference between: $a = $b ?: $c ?: $d; $a = $b ? $c : $d; is non-trivial and the two would do completely different things. This needs to be a function that people can easily look up in the documentation. -Rasmus

« previous php.internals (#10985) next »