Re: Implicit isset/isempty check on short-ternary operator

From: Date: Sat, 16 Apr 2011 23:14:55 +0000
Subject: Re: Implicit isset/isempty check on short-ternary operator
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  Groups: php.internals 
Request: Send a blank email to internals+get-51919@lists.php.net to get a copy of this message
Ben Schmidt wrote: >>> $var = $arr['key'] ?? : 'empty'; > > Also note this is possible with the recent proposal Hannes and I were > discussing. It simply looks like > > $var = $arr?['key'] ?: 'empty'; > > The ?[ avoids notices and the ?: works as it always has. > > Ben. If it was going to be ?[, I'd much prefer $arr['key'?]. It was proposed as $arr[?'key'] instead to avoid a backtracking (would that really be noticeable? I'd prefer readibility), but ?[ would have the same problem.

« previous php.internals (#51919) next »