Re: Implicit isset/isempty check on short-ternary operator
| From: | Etienne Kneuss | Date: | Thu, 07 Apr 2011 22:35:26 +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-51830@lists.php.net to get a copy of this message | ||
On Apr 07 18:03:48, Rasmus Lerdorf 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:
> >
> > $value = isset($a[$key]) ? $a[$key] : 'Not set';
> >
> > which is exactly the situation I had before it was introduced.
>
> Not sure why you would have that expectation. The long ternary doesn't
> do that, and there is nothing about the short ternary that changes that.
> There was talk of a new ifsetor type of operator to have those semantics
> but never any talk of changing existing semantics.
Well it could (and I believe that was the intention) call !empty instead
of isset, that way the semantics would not be changed, appart from the
lack of error for undefined variables.
Best,
>
> -Rasmus
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>