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

From: Date: Thu, 07 Apr 2011 22:12:02 +0000
Subject: Re: Implicit isset/isempty check on short-ternary operator
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-51829@lists.php.net to get a copy of this message
Hello, On Thu, Apr 7, 2011 at 3:03 PM, Rasmus Lerdorf <rasmus@lerdorf.com> wrote: > On 4/7/11 5:59 PM, Matthew Weier O'Phinney wrote: >> >> It may change the semantics as they stand, but I'd argue that the >> _expectation_ from the shorthand ternary is to shorten code that >> currently uses isset(). As it is, I have almost no use for it at this >> point, as I end up needing to do: >> I don't think that changing it to do a implicit isset really fixes the reason developers use it as previously mentioned. My code is littered with isset checks, I would rather see a syntax or operator specifically for this purpose, like ?? since ?: has already been implemented in a different (and in my opinion in all to many cases not a useful) way. Syntax doesn't matter to me though long as it serves my purpose. $var = Array('foo' => 'I am set'); $value = $var['foo'] ?? 'Foo was not set'; // value = "I am set" $value = $var['bar'] ?? 'Bar was not set'; // value ="Bar was not set"; !!no warning!!

« previous php.internals (#51829) next »