I would love to restate my recommendation for the function "filled".
Which is the opposite of "empty".  Filled would accept a variable
number of arguments and return the first where empty evaluates as
false.

Like empty, filled would not throw notices for undefined variables.
This is not the same as the ifsetor debate because filled is opposite
empty and cares not about isset.

-- dante

On 11/21/09, Rasmus Lerdorf <ras...@lerdorf.com> wrote:
> Alban wrote:
>> Le Sat, 21 Nov 2009 09:48:10 +0100, Lukas Kahwe Smith a écrit :
>>
>>> On 21.11.2009, at 06:12, Alban wrote:
>>>
>>>> This is not a big problem but if a solution exists, this would be so
>>>> cool ! Especialy when we have to check existance of twenty or more key
>>>> in array. Code would be be lighter and clear. Since i use PHP, I always
>>>> have in my 'common function file' a function like that :
>>>>
>>>> function getIssetVar($var, $default) { return ((isset($var)) ? $var :
>>>> $default); }
>>>>
>>>> So is it possible to make a little improvement on this operator or
>>>> introduce a new operator or a core function which do that ? What's your
>>>> feeling about it ?
>>>
>>> this feature request has already been discussed and declined:
>>> http://wiki.php.net/rfc/ifsetor
>>>
>>> please review this rfc before continuing this thread.
>>>
>>> regards,
>>> Lukas Kahwe Smith
>>> m...@pooteeweet.org
>>
>> Thanks for the link to the RFC :)
>>
>> Excuse me, but I'll be little hard in this post. This for insult the
>> community but I want the community really think about the decision it
>> made and the reason why.
>>
>> I also read why it have been refused here :
>> http://www.php.net/~derick/meeting-notes.html#ifsetor-as-replacement-for-
>> foo-isset-foo-foo-something-else
>>
>> Is it serious ?
>>
>> «
>> The name for this new operator is heavily disputed and we could not agree
>> on a decent name for it.
>> »
>>
>> Tomorrow I will not send food to the association for children who are
>> hungry because I can not choose between offering Thai or basmati rice.
>>
>> Stop sarcasm, seriously, this is not an honorable response from people
>> making decisions. Take your responsibility and make a vote or impose a
>> name, just do it.
>>
>> «
>>   Instead of implementing ifsetor() we remove the
>>   requirement for the "middle" parameter to the ?: operator.
>> »
>>
>> That's not people wants and that's not do their need.
>> So that not a correct answer of the php developper demand.
>>
>> «
>>   In combination with the new input_filter extension
>>   you then reach the original goal of setting a default
>>   value to a non-set input variable with:
>>
>>   $blahblah = input_filter_get(GET, 'foo', FL_INT) ?: 42;
>> »
>>
>> I don't see how do that with the actual filter extension. Even if it is
>> possible, this is not a pretty short and easier solution than :
>>
>> $var = (isset($var)) ? $var : 'default';
>
> The ternary isn't meant to solve the isset thing you are talking about.
>  It is simply a shortcut to normal ternary operations.  The most common
> case where you don't know if a variable is set is on the initial input
> via $_GET or $_POST and we definitely don't want people doing:
>
>   $var = $_GET['foo'] ?: 42;
>
> It would be an XSS disaster.  Hence the suggestion to use input_filter
> there, or a similar user-supplied filtering function in which case the
> ternary, as it is currently implemented, is perfectly suitable.
>
> -Rasmus
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
Sent from my mobile device

D. Dante Lorenso
da...@lorenso.com
972-333-4139

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to